I created a default console application, and I changed the code on purpose to cause a L3 C4996 warning. The goal was to learn how to use the Treat Warnings as Errors and Treat Specific warnings as errors options. The results are not what I expect. The compiler reported C4996 as an error which I didn't expect since I had not changed the compiler options yet. Why is C4996 reported as an error when the /WX option is still set to no?
#include <iostream>
#include <cstring>
int main()
{
char message[20];
strcpy(message, "Hello World!\n"); // causes C4996
std::cout << message << std::endl;
}
I created a default console application, and I changed the code on purpose to cause a L3 C4996 warning. The goal was to learn how to use the Treat Warnings as Errors and Treat Specific warnings as errors options. The results are not what I expect. The compiler reported C4996 as an error which I didn't expect since I had not changed the compiler options yet. Why is C4996 reported as an error when the /WX option is still set to no?
#include <iostream>
#include <cstring>
int main()
{
char message[20];
strcpy(message, "Hello World!\n"); // causes C4996
std::cout << message << std::endl;
}
Share
Improve this question
edited Feb 7 at 23:42
shawn1874
asked Feb 6 at 19:19
shawn1874shawn1874
1,4511 gold badge13 silver badges29 bronze badges
4
|
1 Answer
Reset to default 2Microsoft documentation for C4996 contains a subtle message that the /sdl option elevates C4996 to an error and /sdl is enabled in a default console application project.
/sdl
enabled? – Eljay Commented Feb 6 at 19:35