When building this very simple test program
#include <iostream>
int main() {
std::cout << "x";
}
with visual studio 2019 and /Wall
I'm getting a
warning C4668: '__STDC_WANT_SECURE_LIB__' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
Trying to
#define __STDC_WANT_SECURE_LIB__ 0
before including iostream results in
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''
at least for my VS. Godbolt doesn't complain.
#define __STDC_WANT_SECURE_LIB__ 1
is fine and doesn't let the compiler complain about sprintf_s which one would expect.
Microsoft doesn't show me any results when searching for it.. SO does here but overall i can't find many resources on if and how to use that define.
Is there a way to disable the secure extensions and include <iostream>
? Am i using the wrong define or approach for this?