www.delorie.com/gnu/docs/gcc/cpp_13.html   search  
 
Buy the book!


The C Preprocessor

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3. Macros

A macro is a fragment of code which has been given a name. Whenever the name is used, it is replaced by the contents of the macro. There are two kinds of macros. They differ mostly in what they look like when they are used. Object-like macros resemble data objects when used, function-like macros resemble function calls.

You may define any valid identifier as a macro, even if it is a C keyword. The preprocessor does not know anything about keywords. This can be useful if you wish to hide a keyword such as const from an older compiler that does not understand it. However, the preprocessor operator defined (see section 4.2.3 Defined) can never be defined as a macro, and C++'s named operators (see section 3.7.4 C++ Named Operators) cannot be macros when you are compiling C++.

3.1 Object-like Macros  
3.2 Function-like Macros  
3.3 Macro Arguments  
3.4 Stringification  
3.5 Concatenation  
3.6 Variadic Macros  
3.7 Predefined Macros  
3.8 Undefining and Redefining Macros  
3.9 Macro Pitfalls  


  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003