[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The option `-traditional' disables certain keywords;
`-ansi' and the various `-std' options disable certain
others. This causes trouble when you want to use GNU C extensions, or
ISO C features, in a general-purpose header file that should be usable
by all programs, including ISO C programs and traditional ones. The
keywords asm
, typeof
and inline
cannot be used
since they won't work in a program compiled with `-ansi'
(although inline
can be used in a program compiled with
`-std=c99'), while the keywords const
, volatile
,
signed
, typeof
and inline
won't work in a program
compiled with `-traditional'. The ISO C99 keyword
restrict
is only available when `-std=gnu99' (which will
eventually be the default) or `-std=c99' (or the equivalent
`-std=iso9899:1999') is used.
The way to solve these problems is to put `__' at the beginning and
end of each problematical keyword. For example, use __asm__
instead of asm
, __const__
instead of const
, and
__inline__
instead of inline
.
Other C compilers won't accept these alternative keywords; if you want to compile with another compiler, you can define the alternate keywords as macros to replace them with the customary keywords. It looks like this:
#ifndef __GNUC__ #define __asm__ asm #endif |
`-pedantic' and other options cause warnings for many GNU C extensions.
You can
prevent such warnings within one expression by writing
__extension__
before the expression. __extension__
has no
effect aside from this.