1. 本人在编译VC工程时,遇到如下错误:
MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _getenv already defined in LIBCMTD.lib(getenv.obj)
MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _free already defined in LIBCMTD.lib(dbgheap.obj)
MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _calloc already defined in LIBCMTD.lib(dbgheap.obj)
MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _malloc already defined in LIBCMTD.lib(dbgheap.obj)
解答:是由于该主程序和其用的lib库所使用的运行库不一致的原因,vc6到project->setting->c/c++->Code Generation->Use run-time library处更改;vc7到c/c++ ->code generation->run-time library处更改。
2. error C2664: 'RpcStringFreeW' : cannot convert parameter 1 from 'unsigned char **__w64 ' to 'RPC_WSTR *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
解决办法:
a:There reason you get the error is that the compiler treat wchar_t as an built-in type, and so TCHAR* maps to wchar_t* and that's not the same as a RPC_WSTR which map to a unsigned short*.To get rid of the error you can change the compiler setting to not treat the wchar_t as an built-in type.
b:"项目属性->常规->字符集"项中的值修改为 "未设置"
3.error C2229: struct 'P_GC_Regist' has an illegal zero-sized array
解决:gnu c里允许存在大小为0的数组作为一个占位符,但是标准c和c++里不允许如此用。