]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/doc/gcc/extensions-to-the-c-language-family/alternate-keywords.rst
sphinx: add missing trailing newline
[thirdparty/gcc.git] / gcc / doc / gcc / extensions-to-the-c-language-family / alternate-keywords.rst
CommitLineData
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
10Alternate Keywords
11******************
12
13:option:`-ansi` and the various :option:`-std` options disable certain
14keywords. This causes trouble when you want to use GNU C extensions, or
15a general-purpose header file that should be usable by all programs,
16including 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
19program compiled with :option:`-std=c99` or a later standard). The
20ISO C99 keyword
21``restrict`` is only available when :option:`-std=gnu99` (which will
22eventually be the default) or :option:`-std=c99` (or the equivalent
23:option:`-std=iso9899:1999`), or an option for a later standard
24version, is used.
25
26The way to solve these problems is to put :samp:`__` at the beginning and
27end of each problematical keyword. For example, use ``__asm__``
28instead of ``asm``, and ``__inline__`` instead of ``inline``.
29
30Other C compilers won't accept these alternative keywords; if you want to
31compile with another compiler, you can define the alternate keywords as
32macros 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.
43You can
44prevent such warnings within one expression by writing
45``__extension__`` before the expression. ``__extension__`` has no
3ed1b4ce 46effect aside from this.