Search code examples
c++visual-studiovisual-c++ansi-c

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


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 Microsoft warnings like

'fscanf': This function or variable may be unsafe. Consider using fscanf_s instead.

I get these despite following some steps on MSDN Developer's site for setting up an ANSI C project, but all the _s ("secure") calls are not ANSI C!

Any suggestions on putting Visual C++ Studio in a strict ANSI-only mode?

Thanks.


Solution

  • One way to suppress specific warnings is to add something like the following to the source.

    #if defined( _WIN32 )
    #pragma warning(disable:4996)
    #endif