VC 几种常见错误的workaround

1>ClCompile:
1>  lib.cpp
1>  _WIN32_WINNT not defined. Defaulting to _WIN32_WINNT_MAXVER (see WinSDKVer.h)
1>d:\softwaredevelop\libjdungeon\libjdungeon\lib.cpp(58): warning C4996: 'std::basic_string<_Elem,_Traits,_Ax>::copy': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\xstring(1555) : see declaration of 'std::basic_string<_Elem,_Traits,_Ax>::copy'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]

Workaround: Solution Explorer ->项目右键-> properties ->Configuration Properties->C/C++ -> Preprocessor->

Preprocessor Definitions->下拉框<Edit...>  ->最末尾增加_SCL_SECURE_NO_WARNINGS

重新编译,即可。

 

1>  Generating Code...
1>uafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in LIBCMTD.lib(new.obj)
1>uafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in LIBCMTD.lib(dbgdel.obj)
1>uafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete[](void *)" (??_V@YAXPAX@Z) already defined in LIBCMTD.lib(delete2.obj)

Description:  There are 'new' & 'delete' operators in both library ( uafxcwd.lib & LIBCMTD.lib).

Because LIBCMTD.lib have defined these operators, when uafxcwd.lib try to define them, the compiler complain.

Solution: 

Solution Explorer ->项目右键-> properties ->Configuration Properties->Linker->Input->

Additional Dependencies->uafxcwd.lib

(input uafxcw.lib when you configure release).

posted @ 2019-07-22 20:49  长老猪  阅读(267)  评论(0编辑  收藏  举报