[英]specifying argument default value in function definition causes error C2143: syntax error : missing ')' before '='
我有以下声明:
DLL EntityHandle scenemanager_create_entity
(SceneManagerHandle handle,
const char* name,
const char* mesh_name,
const char* group_name = 0);
最后一个agrument的默认值group_name = 0
。
当我编译C ++ DLL(/ TP)时它工作正常,并在编译宏DLL时遵循:
#define DLL extern "C" __declspec(dllexport)
但是当我尝试编译与此DLL链接的C应用程序(/ TC)时,它会给出错误C2143:语法错误:在'='之前缺少')'并且宏DLL正在跟随:
#define DLL __declspec(dllimport)
C中没有默认参数。
您可以使用宏__cplusplus
来检查代码是由C ++编译器还是C编译器编译的。
例如
#ifdef __cplusplus
// C++ function declaration...
#else
// C function declaration...
#endif
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.