Setting Visual C++ Studio/Express to strict ANSI mode

后端 未结 3 2067
-上瘾入骨i
-上瘾入骨i 2021-01-18 06:26

I generally program & compile under Linux with gcc and -ansi flag; but I\'ve been forced with doing a job in Visual C++ and whenever I compile my C code I get all the Mi

3条回答
  •  走了就别回头了
    2021-01-18 07:14

    As mentioned in another answer, #define'ing _CRT_SECURE_NO_WARNING will address the specific warnings you mentioned in your question.

    If you're really looking for an ANSI-only mode, the closest thing is the /Za compiler switch. Inside the Visual Studio IDE, you can find it in the project's Properties dialog (under Configuration Properties | C/C++ | Language | Disable Language Extensions).

    Note that virtually all Windows apps build with Microsoft's compiler extensions enabled; e.g., I don't think you'd even be able to consume Windows SDK headers with /Za set. If your code truly is strict ANSI, you should be OK. If you have a few Windows-specific pieces in a project that is mostly strict ANSI, you could probably isolate those sources and only build those indivudal source files with /Za unset.

提交回复
热议问题