[C++ 日常记录] #3 VS 中 MSVC 编译器选项中的 /sdl (Enable Additional Security Checks)
Visual Studio 中默认开启 SDL 检查,某些警告会成为错误,使得程序编译不通过,例如:
error C4146: unary minus operator applied to unsigned type, result still unsigned
具体地,SDL 检查设计的警告有:
关闭 SDL 检查 的方法
Project -- Property -- Configuration Properties -- C/C++ -- General
在 SDL checks 选项处,选择 No(/sdl-)
另外,若仅想排除对某一指定警告的相关功能,使用 /wd 指令即可,可参考相关网页
Project -- Property -- Configuration Properties -- C/C++ -- Command Line
附:什么是 SDL 检查
SDL 检查是微软为了提高安全相关而专门设计的功能之一:
参考:微软官方文档