How to ensure my code is ansi C, no C++ involved. Could compiler like gcc can be set to prompt error when meeting feature in C++? -
i programmed c++ while. want program ansi c program, don't want "c++ only" feature in code. i'm using cygwin 64 bit gcc installed. there settings let gcc prompt compiler error if encounter c++ features? e.g. stl.
thank in advance.
the following taken gcc documentation:
the original ansi c standard (x3.159-1989) ratified in 1989 , published in 1990. standard ratified iso standard (iso/iec 9899:1990) later in 1990. there no technical differences between these publications, although sections of ansi standard renumbered , became clauses in iso standard. standard, in both forms, commonly known c89, or c90, dates of ratification. ansi standard, not iso standard, came rationale document. select standard in gcc, use 1 of options -ansi, -std=c90 or -std=iso9899:1990; obtain diagnostics required standard, should specify -pedantic (or -pedantic-errors if want them errors rather warnings).
so, compile using following flags:
gcc myfile.c -ansi -pedantic-errors
notice -ansi , -std=c90 synonyms. full list of options, refer options controlling c dialect.
Comments
Post a Comment