18.4. C DialectsWhen writing a C program, one of your first tasks is to decide which of the various definitions of the C language applies to your program. GCC's default dialect is "GNU C," which is largely the ISO/IEC 9899:1990 standard, with its published corrigenda, and with a number of language extensions. These extensions include many features that have since been standardized in C99such as complex floating-point types and long long integersas well as other features that have not been adopted, such as complex integer types and zero-length arrays. The full list of extensions is provided in the GCC documentation. To turn off all the GNU C extensions, use the command-line option -ansi. This book describes C as defined in ISO/IEC 9899:1999, or "C99." GCC adheres (not yet completely, but nearly so) to C99 if you use the command-line option -std=c99, and we have done so in testing the examples in this book. GCC's language standardization options are:
With any of these options, you must also add the option -pedantic if you want GCC to issue all the warnings that are required by the given standard version, and to reject all extensions that are prohibited by the standard. The option -pedantic-errors causes compiling to fail when such warnings occur. Earlier versions of GCC also offered a -traditional option, which was intended to provide support for pre-ANSI or "K&R-style" C. Currently GCC supports this option only in the preprocessing stage, and accepts it only in conjunction with the -E option, which directs GCC to perform preprocessing and then exit. Furthermore, a number of GCC options allow you to enable or disable individual aspects of different standards and extensions. For example, the -trigraphs option enables trigraphs (see "Digraphs and Trigraphs" in Chapter 1) even if you have not used the -ansi option. For the full list of available dialect options, see the GCC manual. |