]>
Commit | Line | Data |
---|---|---|
c63539ff ML |
1 | .. |
2 | Copyright 1988-2022 Free Software Foundation, Inc. | |
3 | This is part of the GCC manual. | |
4 | For copying conditions, see the copyright.rst file. | |
5 | ||
6 | .. index:: alternate keywords, keywords, alternate | |
7 | ||
8 | .. _alternate-keywords: | |
9 | ||
10 | Alternate Keywords | |
11 | ****************** | |
12 | ||
13 | :option:`-ansi` and the various :option:`-std` options disable certain | |
14 | keywords. This causes trouble when you want to use GNU C extensions, or | |
15 | a general-purpose header file that should be usable by all programs, | |
16 | including ISO C programs. The keywords ``asm``, ``typeof`` and | |
17 | ``inline`` are not available in programs compiled with | |
18 | :option:`-ansi` or :option:`-std` (although ``inline`` can be used in a | |
19 | program compiled with :option:`-std=c99` or a later standard). The | |
20 | ISO C99 keyword | |
21 | ``restrict`` is only available when :option:`-std=gnu99` (which will | |
22 | eventually be the default) or :option:`-std=c99` (or the equivalent | |
23 | :option:`-std=iso9899:1999`), or an option for a later standard | |
24 | version, is used. | |
25 | ||
26 | The way to solve these problems is to put :samp:`__` at the beginning and | |
27 | end of each problematical keyword. For example, use ``__asm__`` | |
28 | instead of ``asm``, and ``__inline__`` instead of ``inline``. | |
29 | ||
30 | Other C compilers won't accept these alternative keywords; if you want to | |
31 | compile with another compiler, you can define the alternate keywords as | |
32 | macros to replace them with the customary keywords. It looks like this: | |
33 | ||
34 | .. code-block:: c++ | |
35 | ||
36 | #ifndef __GNUC__ | |
37 | #define __asm__ asm | |
38 | #endif | |
39 | ||
40 | .. index:: __extension__, pedantic | |
41 | ||
42 | :option:`-pedantic` and other options cause warnings for many GNU C extensions. | |
43 | You can | |
44 | prevent such warnings within one expression by writing | |
45 | ``__extension__`` before the expression. ``__extension__`` has no | |
3ed1b4ce | 46 | effect aside from this. |