1. 警告消息 'function': was declared deprecated
Compiler Warning (level 1) C4996
Error Message
'function': was declared deprecatedThe compiler encountered a function that was marked with deprecated. The function may no longer be supported in a future release. You can turn this warning off with thewarning pragma (example below).
C4996 is generated for the line on which the function is declared and for the line on which the function is used.
You will see C4996 if you are using members of the <hash_map> and <hash_set> header files in the std namespace. SeeThe stdext Namespace for more information.
Some CRT and Standard C++ Library functions have been deprecated in favor of new, more secure functions. For more information on deprecated functions, seeSecurity Enhancements in the CRT andSafe Libraries: Standard C++ Library.
C4996 can also occur if you use MFC or ATL functions that were deprecated for security reasons. To suppress these warnings, see_AFX_SECURE_NO_WARNINGS and_ATL_SECURE_NO_WARNINGS.
Example//z 2012-1-18 11:29 AM IS2120@CSDN
The following sample generates C4996.
// C4996.cpp // compile with: /W1 // C4996 warning expected #include <stdio.h> // #pragma warning(disable : 4996) void func1(void) { printf_s("\nIn func1"); } __declspec(deprecated) void func1(int) { printf_s("\nIn func2"); } int main() { func1(); func1(1); }
C4996 can also occur if you do not use a checked iterator when compiling with _SECURE_SCL 1. SeeChecked Iterators for more information.
The following sample generates C4996.
// C4996_b.cpp // compile with: /EHsc /W1 #define _SECURE_SCL 1 #include <algorithm> using namespace std; using namespace stdext; int main() { int a [] = {1, 2, 3}; int b [] = {10, 11, 12}; copy(a, a + 3, b); // C4996 copy(a, a + 3, checked_array_iterator<int *>(b, 3)); // OK }
2. 消除的几种方法(不建议正式的项目中使用,只是用于自己做的一些小工具项目)
Calling any one of the potentially unsafe methods in the Standard C++ Library will result inCompiler Warning (level 1) C4996. To disable this warning, define the macro_SCL_SECURE_NO_WARNINGS in your code:
2.1 #define _SCL_SECURE_NO_WARNINGS
Other ways to disable warning C4996 include:
-
2.2 Using the /D (Preprocessor Definitions)compiler option:
cl /D_SCL_SECURE_NO_WARNINGS [other compiler options] myfile.cpp
-
2.3 Using the /w compiler option:
cl /wd4996 [other compiler options] myfile.cpp
-
2.4 Using the #pragma warning directive:
#pragma warning(disable:4996)
Also, you can manually change the level of warning C4996 with the /w<l><n> compiler option. For example, to set warning C4996 to level 4:
2.5 cl /w44996 [other compiler options] myfile.cpp
http://blog.csdn.net/is2120/article/details/7208770
3. 遇到一个链接错误 unresolved external symbol "const type_info::`vftable'" (??_7type_info@@6B@)
The symbol is defined in msvcrt.lib. You are not linking with that library because you specified the /NODEFAULTLIB linker option. Either remove that option, or add msvcrt.lib as an input library. Thanks for taking the time to report this!
Mitchell Slep
Visual C++ Compiler Team
RTTI is on by default in Visual C++ 2005, so you need to explicitly disable it by adding /GR- to the command line.
Thank you,
Dean Wills
Visual C++ Team