问题描述
构建这个非常简单的测试程序时
#include <iostream>
int main() {
std::cout << "x";
}
使用 Visual Studio 2019 和 /Wall
我得到了
warning C4668: '__STDC_WANT_SECURE_LIB__' is not defined as a preprocessor macro,replacing with '0' for '#if/#elif'
尝试
#define __STDC_WANT_SECURE_LIB__ 0
在包含 iostream 结果之前
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\include\xlocnum(1388,69): error C2039: 'sprintf_s': is not a member of '`global namespace''
至少对于我的 VS。 Godbolt doesn't complain。
#define __STDC_WANT_SECURE_LIB__ 1
很好,不会让编译器抱怨 sprintf_s 是人们所期望的。
Microsoft doesn't show me any results when searching for it.。 SO 确实 here 但总的来说我找不到很多关于是否以及如何使用该定义的资源。
有没有办法禁用安全扩展并包含 <iostream>
?我是否为此使用了错误的定义或方法?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)