Noeud:C Language Features, Noeud « Next »:, Noeud « Up »:Useful GCC Options



C Language Features

Depending on how old your code is, and how much you have stayed in line with ANSI C, there are a number of switches to deal with compiling your C source files1.

-traditional Supports the traditional C language, including lots of questionable, but common, practices. The traditional option also supports all of the FSF's extensions to the C language.
-ansi Supports the ANSI C standard, though somewhat loosely. The FSF's extensions are recognised, except for a few that are incompatible with the ANSI standard. Thus ANSI programs compile correctly, but the compiler doesn't try too hard to reject non-conformatnt programs, or programs using non-ANSI features.
-pedantic Issues all the warning messages that are required by the ANSI C standard. Forbids the use of all the FSF extensions to the C language and considers the use of such extensions errors. It's arguable whether or not anyone wants this degree of conformity to the ANSI standard. The FSF obviously feels that it isn't really necessary; they write "This option is not intended to be useful; it exists only to satisfy pedants." We feel that it's useful to check for ANSI conformity at this level and also that it's useful to disable the FSF's own extensions to the language. As the gcc manual points out, -pedantic is not a complete check for ansi conformance - it only issues errors that are required by the ANSI standard.


Notes de bas de page

  1. The following options, -traditional, -ansi and -pedantic, are taken verbatim from the first edition. Also, see Standards Conformance for a little bit more about the ISO standards etc.