]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/doc/cpp/macros.rst
sphinx: add missing trailing newline
[thirdparty/gcc.git] / gcc / doc / cpp / macros.rst
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 .. _macros:
7
8 Macros
9 ------
10
11 A :dfn:`macro` is a fragment of code which has been given a name.
12 Whenever the name is used, it is replaced by the contents of the macro.
13 There are two kinds of macros. They differ mostly in what they look
14 like when they are used. :dfn:`Object-like` macros resemble data objects
15 when used, :dfn:`function-like` macros resemble function calls.
16
17 You may define any valid identifier as a macro, even if it is a C
18 keyword. The preprocessor does not know anything about keywords. This
19 can be useful if you wish to hide a keyword such as ``const`` from an
20 older compiler that does not understand it. However, the preprocessor
21 operator ``defined`` (see :ref:`defined`) can never be defined as a
22 macro, and C++'s named operators (see :ref:`c++-named-operators`) cannot be
23 macros when you are compiling C++.
24
25 .. toctree::
26 :maxdepth: 2
27
28 macros/object-like-macros
29 macros/function-like-macros
30 macros/macro-arguments
31 macros/stringizing
32 macros/concatenation
33 macros/variadic-macros
34 macros/predefined-macros
35 macros/undefining-and-redefining-macros
36 macros/directives-within-macro-arguments
37 macros/macro-pitfalls