Alternate Keywords (Using the GNU Compiler Collection (GCC)) (original) (raw)
6.12.21 Alternate Keywords ¶
-ansi and the various -std options disable certain keywords that are GNU C extensions. Specifically, the keywords asm
, typeof
andinline
are not available in programs compiled with-ansi or a -std= option specifying an ISO standard that doesn’t define the keyword. This causes trouble when you want to use these extensions in a header file that can be included in programs that may be compiled with with such options.
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
, 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 suppress such warnings using the keyword __extension__
. Specifically:
- Writing
__extension__
before an expression prevents warnings about extensions within that expression. - In C, writing:
suppresses warnings about using ‘[[]]’ attributes in C versions that predate C23.
__extension__
has no effect aside from this.