我定义了这样的类型:
typedef char sType[256];
和一个函数,带有默认参数:
void foo(const sType param = NULL);
MinGW (g++ 4.8.0( 编译它没有错误。
相反,Visual Studio 2015 (Tools 14.0( 给出以下错误:
error C2040: 'sType': 'int' differs in levels of indirection from 'char [256]'
我试图将NULL
投射到const char[]
,但这会导致:
error C2440: 'type cast': cannot convert from 'int' to 'const char []'
有什么提示吗?谢谢
投NULL
不是为了const char[]
(或sType
(,而是为了const char*
。 函数参数在声明中经历数组到指针的衰减。