c++cmingwc99

MinGW Compiler for Windows, using GCC, C99 vs GNU99


I am using the MinGW compiler for Windows. I am making some programs in C. Most of the articles I read up on this seem to be outdated... last I read C99 was incomplete in the GCC is this still true? My real question is cross platform compatibility between setting C99 and GNU99... should I avoid using GNU99 setting and it's extensions and just stick with C99? I am new to this MinGW compiler set as I have always used Visual Studio and decided to try something new... right now I am compiling with these settings...

-march=native -O3 -std=gnu99

Is there any recommended compiler commands I should enter for making C programs and also for making C++ programs with this compiler?

I want to make a simple program that is compatible with Windows, Mac, & Linux but first most Windows.


Solution

  • With respect to C, Visual Studio until recently did not support C99 at all.

    With respect to gcc you can find a detailed detailed writeup on which standard they support and the nooks and crannies involved. They also have a nice list of extensions they support. You need to be a little careful with gcc and extensions because just specifying which standard you want to use is not enough to generate a warning or error when you are using an extension. For example you might be surprised that using:

    gcc -std=c90 -W -Wall
    

    allows you to use variable length arrays without a warning. In order to generate a warning you need to add -pedantic:

    gcc -std=c90 -W -Wall -pedantic
    

    and then this will generate a warning similar to this:

    warning: ISO C90 forbids variable length array ‘array’ [-Wvla]