跳至主要內容

错误与提示

chanchaw大约 1 分钟cpp

未定义标识符string

默认创建的项目都是不支持 string 类的,要添加下面代码的包含头文件,两行代码缺一不可,可以将双冒号的 string 替换为尖括号的 string

#include "string"
using namespace std;

预处理器

使用了过时的函数时,IDE会提示如下:

严重性   代码 说明 项目 文件 行  禁止显示状态
错误 C4996 'mbstowcs': This function or variable may be unsafe. Consider using mbstowcs_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.  FileManager d:\source\cpp\filemanager\filemanager\filemanager.cpp 37

只要将提示中的 _CRT_SECURE_NO_WARNINGS 添加到预处理器中即可 预处理器

错误 C4996,This function or variable may be unsafe

使用的函数或者变量不安全,建议使用新版本更安全的方式,完整提示如下:

提示

严重性 代码 说明 项目 文件 行 禁止显示状态 错误 C4996 'freopen': This function or variable may be unsafe.Consider using freopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS.See online help for details.mountMainThread d : \source\cpp\windowsapi\mountmainthread\pluginmainwindow.cpp 58

上面提示函数 freopen 是不安全的,建议使用 freopen ,或者也可以通过使用 _CRT_SECURE_NO_WARNINGS 关闭该提示,关闭提示的方法如下:
cpp添加预处理器