home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 6 / FreshFish_September1994.bin / bbs / gnu / gcc-2.6.0-src.lha / GNU / src / amiga / gcc-2.6.0 / cpp.info-1 < prev    next >
Encoding:
GNU Info File  |  1994-07-14  |  48.2 KB  |  1,185 lines

  1. This is Info file cpp.info, produced by Makeinfo-1.54 from the input
  2. file cpp.texi.
  3.  
  4.    This file documents the GNU C Preprocessor.
  5.  
  6.    Copyright 1987, 1989, 1991, 1992, 1993 Free Software Foundation, Inc.
  7.  
  8.    Permission is granted to make and distribute verbatim copies of this
  9. manual provided the copyright notice and this permission notice are
  10. preserved on all copies.
  11.  
  12.    Permission is granted to copy and distribute modified versions of
  13. this manual under the conditions for verbatim copying, provided also
  14. that the entire resulting derived work is distributed under the terms
  15. of a permission notice identical to this one.
  16.  
  17.    Permission is granted to copy and distribute translations of this
  18. manual into another language, under the above conditions for modified
  19. versions.
  20.  
  21. 
  22. File: cpp.info,  Node: Top,  Next: Global Actions,  Up: (DIR)
  23.  
  24. The C Preprocessor
  25. ******************
  26.  
  27.    The C preprocessor is a "macro processor" that is used automatically
  28. by the C compiler to transform your program before actual compilation.
  29. It is called a macro processor because it allows you to define "macros",
  30. which are brief abbreviations for longer constructs.
  31.  
  32.    The C preprocessor provides four separate facilities that you can
  33. use as you see fit:
  34.  
  35.    * Inclusion of header files.  These are files of declarations that
  36.      can be substituted into your program.
  37.  
  38.    * Macro expansion.  You can define "macros", which are abbreviations
  39.      for arbitrary fragments of C code, and then the C preprocessor will
  40.      replace the macros with their definitions throughout the program.
  41.  
  42.    * Conditional compilation.  Using special preprocessor commands, you
  43.      can include or exclude parts of the program according to various
  44.      conditions.
  45.  
  46.    * Line control.  If you use a program to combine or rearrange source
  47.      files into an intermediate file which is then compiled, you can
  48.      use line control to inform the compiler of where each source line
  49.      originally came from.
  50.  
  51.    C preprocessors vary in some details.  This manual discusses the GNU
  52. C preprocessor, the C Compatible Compiler Preprocessor.  The GNU C
  53. preprocessor provides a superset of the features of ANSI Standard C.
  54.  
  55.    ANSI Standard C requires the rejection of many harmless constructs
  56. commonly used by today's C programs.  Such incompatibility would be
  57. inconvenient for users, so the GNU C preprocessor is configured to
  58. accept these constructs by default.  Strictly speaking, to get ANSI
  59. Standard C, you must use the options `-trigraphs', `-undef' and
  60. `-pedantic', but in practice the consequences of having strict ANSI
  61. Standard C make it undesirable to do this.  *Note Invocation::.
  62.  
  63. * Menu:
  64.  
  65. * Global Actions::    Actions made uniformly on all input files.
  66. * Commands::          General syntax of preprocessor commands.
  67. * Header Files::      How and why to use header files.
  68. * Macros::            How and why to use macros.
  69. * Conditionals::      How and why to use conditionals.
  70. * Combining Sources:: Use of line control when you combine source files.
  71. * Other Commands::    Miscellaneous preprocessor commands.
  72. * Output::            Format of output from the C preprocessor.
  73. * Invocation::        How to invoke the preprocessor; command options.
  74. * Concept Index::     Index of concepts and terms.
  75. * Index::             Index of commands, predefined macros and options.
  76.  
  77. 
  78. File: cpp.info,  Node: Global Actions,  Next: Commands,  Prev: Top,  Up: Top
  79.  
  80. Transformations Made Globally
  81. =============================
  82.  
  83.    Most C preprocessor features are inactive unless you give specific
  84. commands to request their use.  (Preprocessor commands are lines
  85. starting with `#'; *note Commands::.).  But there are three
  86. transformations that the preprocessor always makes on all the input it
  87. receives, even in the absence of commands.
  88.  
  89.    * All C comments are replaced with single spaces.
  90.  
  91.    * Backslash-Newline sequences are deleted, no matter where.  This
  92.      feature allows you to break long lines for cosmetic purposes
  93.      without changing their meaning.
  94.  
  95.    * Predefined macro names are replaced with their expansions (*note
  96.      Predefined::.).
  97.  
  98.    The first two transformations are done *before* nearly all other
  99. parsing and before preprocessor commands are recognized.  Thus, for
  100. example, you can split a line cosmetically with Backslash-Newline
  101. anywhere (except when trigraphs are in use; see below).
  102.  
  103.      /*
  104.      */ # /*
  105.      */ defi\
  106.      ne FO\
  107.      O 10\
  108.      20
  109.  
  110. is equivalent into `#define FOO 1020'.  You can split even an escape
  111. sequence with Backslash-Newline.  For example, you can split `"foo\bar"'
  112. between the `\' and the `b' to get
  113.  
  114.      "foo\\
  115.      bar"
  116.  
  117. This behavior is unclean: in all other contexts, a Backslash can be
  118. inserted in a string constant as an ordinary character by writing a
  119. double Backslash, and this creates an exception.  But the ANSI C
  120. standard requires it.  (Strict ANSI C does not allow Newlines in string
  121. constants, so they do not consider this a problem.)
  122.  
  123.    But there are a few exceptions to all three transformations.
  124.  
  125.    * C comments and predefined macro names are not recognized inside a
  126.      `#include' command in which the file name is delimited with `<'
  127.      and `>'.
  128.  
  129.    * C comments and predefined macro names are never recognized within a
  130.      character or string constant.  (Strictly speaking, this is the
  131.      rule, not an exception, but it is worth noting here anyway.)
  132.  
  133.    * Backslash-Newline may not safely be used within an ANSI "trigraph".
  134.      Trigraphs are converted before Backslash-Newline is deleted.  If
  135.      you write what looks like a trigraph with a Backslash-Newline
  136.      inside, the Backslash-Newline is deleted as usual, but it is then
  137.      too late to recognize the trigraph.
  138.  
  139.      This exception is relevant only if you use the `-trigraphs' option
  140.      to enable trigraph processing.  *Note Invocation::.
  141.  
  142. 
  143. File: cpp.info,  Node: Commands,  Next: Header Files,  Prev: Global Actions,  Up: Top
  144.  
  145. Preprocessor Commands
  146. =====================
  147.  
  148.    Most preprocessor features are active only if you use preprocessor
  149. commands to request their use.
  150.  
  151.    Preprocessor commands are lines in your program that start with `#'.
  152. The `#' is followed by an identifier that is the "command name".  For
  153. example, `#define' is the command that defines a macro.  Whitespace is
  154. also allowed before and after the `#'.
  155.  
  156.    The set of valid command names is fixed.  Programs cannot define new
  157. preprocessor commands.
  158.  
  159.    Some command names require arguments; these make up the rest of the
  160. command line and must be separated from the command name by whitespace.
  161. For example, `#define' must be followed by a macro name and the
  162. intended expansion of the macro.  *Note Simple Macros::.
  163.  
  164.    A preprocessor command cannot be more than one line in normal
  165. circumstances.  It may be split cosmetically with Backslash-Newline,
  166. but that has no effect on its meaning.  Comments containing Newlines
  167. can also divide the command into multiple lines, but the comments are
  168. changed to Spaces before the command is interpreted.  The only way a
  169. significant Newline can occur in a preprocessor command is within a
  170. string constant or character constant.  Note that most C compilers that
  171. might be applied to the output from the preprocessor do not accept
  172. string or character constants containing Newlines.
  173.  
  174.    The `#' and the command name cannot come from a macro expansion.  For
  175. example, if `foo' is defined as a macro expanding to `define', that
  176. does not make `#foo' a valid preprocessor command.
  177.  
  178. 
  179. File: cpp.info,  Node: Header Files,  Next: Macros,  Prev: Commands,  Up: Top
  180.  
  181. Header Files
  182. ============
  183.  
  184.    A header file is a file containing C declarations and macro
  185. definitions (*note Macros::.) to be shared between several source
  186. files.  You request the use of a header file in your program with the C
  187. preprocessor command `#include'.
  188.  
  189. * Menu:
  190.  
  191. * Header Uses::         What header files are used for.
  192. * Include Syntax::      How to write `#include' commands.
  193. * Include Operation::   What `#include' does.
  194. * Once-Only::        Preventing multiple inclusion of one header file.
  195. * Inheritance::         Including one header file in another header file.
  196.  
  197. 
  198. File: cpp.info,  Node: Header Uses,  Next: Include Syntax,  Prev: Header Files,  Up: Header Files
  199.  
  200. Uses of Header Files
  201. --------------------
  202.  
  203.    Header files serve two kinds of purposes.
  204.  
  205.    * System header files declare the interfaces to parts of the
  206.      operating system.  You include them in your program to supply the
  207.      definitions and declarations you need to invoke system calls and
  208.      libraries.
  209.  
  210.    * Your own header files contain declarations for interfaces between
  211.      the source files of your program.  Each time you have a group of
  212.      related declarations and macro definitions all or most of which
  213.      are needed in several different source files, it is a good idea to
  214.      create a header file for them.
  215.  
  216.    Including a header file produces the same results in C compilation as
  217. copying the header file into each source file that needs it.  But such
  218. copying would be time-consuming and error-prone.  With a header file,
  219. the related declarations appear in only one place.  If they need to be
  220. changed, they can be changed in one place, and programs that include
  221. the header file will automatically use the new version when next
  222. recompiled.  The header file eliminates the labor of finding and
  223. changing all the copies as well as the risk that a failure to find one
  224. copy will result in inconsistencies within a program.
  225.  
  226.    The usual convention is to give header files names that end with
  227. `.h'.  Avoid unusual characters in header file names, as they reduce
  228. portability.
  229.  
  230. 
  231. File: cpp.info,  Node: Include Syntax,  Next: Include Operation,  Prev: Header Uses,  Up: Header Files
  232.  
  233. The `#include' Command
  234. ----------------------
  235.  
  236.    Both user and system header files are included using the preprocessor
  237. command `#include'.  It has three variants:
  238.  
  239. `#include <FILE>'
  240.      This variant is used for system header files.  It searches for a
  241.      file named FILE in a list of directories specified by you, then in
  242.      a standard list of system directories.  You specify directories to
  243.      search for header files with the command option `-I' (*note
  244.      Invocation::.).  The option `-nostdinc' inhibits searching the
  245.      standard system directories; in this case only the directories you
  246.      specify are searched.
  247.  
  248.      The parsing of this form of `#include' is slightly special because
  249.      comments are not recognized within the `<...>'.  Thus, in
  250.      `#include <x/*y>' the `/*' does not start a comment and the
  251.      command specifies inclusion of a system header file named `x/*y'.
  252.      Of course, a header file with such a name is unlikely to exist on
  253.      Unix, where shell wildcard features would make it hard to
  254.      manipulate.
  255.  
  256.      The argument FILE may not contain a `>' character.  It may,
  257.      however, contain a `<' character.
  258.  
  259. `#include "FILE"'
  260.      This variant is used for header files of your own program.  It
  261.      searches for a file named FILE first in the current directory,
  262.      then in the same directories used for system header files.  The
  263.      current directory is the directory of the current input file.  It
  264.      is tried first because it is presumed to be the location of the
  265.      files that the current input file refers to.  (If the `-I-' option
  266.      is used, the special treatment of the current directory is
  267.      inhibited.)
  268.  
  269.      The argument FILE may not contain `"' characters.  If backslashes
  270.      occur within FILE, they are considered ordinary text characters,
  271.      not escape characters.  None of the character escape sequences
  272.      appropriate to string constants in C are processed.  Thus,
  273.      `#include "x\n\\y"' specifies a filename containing three
  274.      backslashes.  It is not clear why this behavior is ever useful, but
  275.      the ANSI standard specifies it.
  276.  
  277. `#include ANYTHING ELSE'
  278.      This variant is called a "computed #include".  Any `#include'
  279.      command whose argument does not fit the above two forms is a
  280.      computed include.  The text ANYTHING ELSE is checked for macro
  281.      calls, which are expanded (*note Macros::.).  When this is done,
  282.      the result must fit one of the above two variants--in particular,
  283.      the expanded text must in the end be surrounded by either quotes
  284.      or angle braces.
  285.  
  286.      This feature allows you to define a macro which controls the file
  287.      name to be used at a later point in the program.  One application
  288.      of this is to allow a site-specific configuration file for your
  289.      program to specify the names of the system include files to be
  290.      used.  This can help in porting the program to various operating
  291.      systems in which the necessary system header files are found in
  292.      different places.
  293.  
  294. 
  295. File: cpp.info,  Node: Include Operation,  Next: Once-Only,  Prev: Include Syntax,  Up: Header Files
  296.  
  297. How `#include' Works
  298. --------------------
  299.  
  300.    The `#include' command works by directing the C preprocessor to scan
  301. the specified file as input before continuing with the rest of the
  302. current file.  The output from the preprocessor contains the output
  303. already generated, followed by the output resulting from the included
  304. file, followed by the output that comes from the text after the
  305. `#include' command.  For example, given a header file `header.h' as
  306. follows,
  307.  
  308.      char *test ();
  309.  
  310. and a main program called `program.c' that uses the header file, like
  311. this,
  312.  
  313.      int x;
  314.      #include "header.h"
  315.      
  316.      main ()
  317.      {
  318.        printf (test ());
  319.      }
  320.  
  321. the output generated by the C preprocessor for `program.c' as input
  322. would be
  323.  
  324.      int x;
  325.      char *test ();
  326.      
  327.      main ()
  328.      {
  329.        printf (test ());
  330.      }
  331.  
  332.    Included files are not limited to declarations and macro
  333. definitions; those are merely the typical uses.  Any fragment of a C
  334. program can be included from another file.  The include file could even
  335. contain the beginning of a statement that is concluded in the
  336. containing file, or the end of a statement that was started in the
  337. including file.  However, a comment or a string or character constant
  338. may not start in the included file and finish in the including file.
  339. An unterminated comment, string constant or character constant in an
  340. included file is considered to end (with an error message) at the end
  341. of the file.
  342.  
  343.    It is possible for a header file to begin or end a syntactic unit
  344. such as a function definition, but that would be very confusing, so
  345. don't do it.
  346.  
  347.    The line following the `#include' command is always treated as a
  348. separate line by the C preprocessor even if the included file lacks a
  349. final newline.
  350.  
  351. 
  352. File: cpp.info,  Node: Once-Only,  Next: Inheritance,  Prev: Include Operation,  Up: Header Files
  353.  
  354. Once-Only Include Files
  355. -----------------------
  356.  
  357.    Very often, one header file includes another.  It can easily result
  358. that a certain header file is included more than once.  This may lead
  359. to errors, if the header file defines structure types or typedefs, and
  360. is certainly wasteful.  Therefore, we often wish to prevent multiple
  361. inclusion of a header file.
  362.  
  363.    The standard way to do this is to enclose the entire real contents
  364. of the file in a conditional, like this:
  365.  
  366.      #ifndef FILE_FOO_SEEN
  367.      #define FILE_FOO_SEEN
  368.      
  369.      THE ENTIRE FILE
  370.      
  371.      #endif /* FILE_FOO_SEEN */
  372.  
  373.    The macro `FILE_FOO_SEEN' indicates that the file has been included
  374. once already.  In a user header file, the macro name should not begin
  375. with `_'.  In a system header file, this name should begin with `__' to
  376. avoid conflicts with user programs.  In any kind of header file, the
  377. macro name should contain the name of the file and some additional
  378. text, to avoid conflicts with other header files.
  379.  
  380.    The GNU C preprocessor is programmed to notice when a header file
  381. uses this particular construct and handle it efficiently.  If a header
  382. file is contained entirely in a `#ifndef' conditional, then it records
  383. that fact.  If a subsequent `#include' specifies the same file, and the
  384. macro in the `#ifndef' is already defined, then the file is entirely
  385. skipped, without even reading it.
  386.  
  387.    There is also an explicit command to tell the preprocessor that it
  388. need not include a file more than once.  This is called `#pragma once',
  389. and was used *in addition to* the `#ifndef' conditional around the
  390. contents of the header file.  `#pragma once' is now obsolete and should
  391. not be used at all.
  392.  
  393.    In the Objective C language, there is a variant of `#include' called
  394. `#import' which includes a file, but does so at most once.  If you use
  395. `#import' *instead of* `#include', then you don't need the conditionals
  396. inside the header file to prevent multiple execution of the contents.
  397.  
  398.    `#import' is obsolete because it is not a well designed feature.  It
  399. requires the users of a header file--the applications programmers--to
  400. know that a certain header file should only be included once.  It is
  401. much better for the header file's implementor to write the file so that
  402. users don't need to know this.  Using `#ifndef' accomplishes this goal.
  403.  
  404. 
  405. File: cpp.info,  Node: Inheritance,  Prev: Once-Only,  Up: Header Files
  406.  
  407. Inheritance and Header Files
  408. ----------------------------
  409.  
  410.    "Inheritance" is what happens when one object or file derives some
  411. of its contents by virtual copying from another object or file.  In the
  412. case of C header files, inheritance means that one header file includes
  413. another header file and then replaces or adds something.
  414.  
  415.    If the inheriting header file and the base header file have different
  416. names, then inheritance is straightforward: simply write `#include
  417. "BASE"' in the inheriting file.
  418.  
  419.    Sometimes it is necessary to give the inheriting file the same name
  420. as the base file.  This is less straightforward.
  421.  
  422.    For example, suppose an application program uses the system header
  423. file `sys/signal.h', but the version of `/usr/include/sys/signal.h' on
  424. a particular system doesn't do what the application program expects.
  425. It might be convenient to define a "local" version, perhaps under the
  426. name `/usr/local/include/sys/signal.h', to override or add to the one
  427. supplied by the system.
  428.  
  429.    You can do this by using the option `-I.' for compilation, and
  430. writing a file `sys/signal.h' that does what the application program
  431. expects.  But making this file include the standard `sys/signal.h' is
  432. not so easy--writing `#include <sys/signal.h>' in that file doesn't
  433. work, because it includes your own version of the file, not the
  434. standard system version.  Used in that file itself, this leads to an
  435. infinite recursion and a fatal error in compilation.
  436.  
  437.    `#include </usr/include/sys/signal.h>' would find the proper file,
  438. but that is not clean, since it makes an assumption about where the
  439. system header file is found.  This is bad for maintenance, since it
  440. means that any change in where the system's header files are kept
  441. requires a change somewhere else.
  442.  
  443.    The clean way to solve this problem is to use `#include_next', which
  444. means, "Include the *next* file with this name."  This command works
  445. like `#include' except in searching for the specified file: it starts
  446. searching the list of header file directories *after* the directory in
  447. which the current file was found.
  448.  
  449.    Suppose you specify `-I /usr/local/include', and the list of
  450. directories to search also includes `/usr/include'; and suppose that
  451. both directories contain a file named `sys/signal.h'.  Ordinary
  452. `#include <sys/signal.h>' finds the file under `/usr/local/include'.
  453. If that file contains `#include_next <sys/signal.h>', it starts
  454. searching after that directory, and finds the file in `/usr/include'.
  455.  
  456. 
  457. File: cpp.info,  Node: Macros,  Next: Conditionals,  Prev: Header Files,  Up: Top
  458.  
  459. Macros
  460. ======
  461.  
  462.    A macro is a sort of abbreviation which you can define once and then
  463. use later.  There are many complicated features associated with macros
  464. in the C preprocessor.
  465.  
  466. * Menu:
  467.  
  468. * Simple Macros::    Macros that always expand the same way.
  469. * Argument Macros::  Macros that accept arguments that are substituted
  470.                        into the macro expansion.
  471. * Predefined::       Predefined macros that are always available.
  472. * Stringification::  Macro arguments converted into string constants.
  473. * Concatenation::    Building tokens from parts taken from macro arguments.
  474. * Undefining::       Cancelling a macro's definition.
  475. * Redefining::       Changing a macro's definition.
  476. * Macro Pitfalls::   Macros can confuse the unwary.  Here we explain
  477.                        several common problems and strange features.
  478.  
  479. 
  480. File: cpp.info,  Node: Simple Macros,  Next: Argument Macros,  Prev: Macros,  Up: Macros
  481.  
  482. Simple Macros
  483. -------------
  484.  
  485.    A "simple macro" is a kind of abbreviation.  It is a name which
  486. stands for a fragment of code.  Some people refer to these as "manifest
  487. constants".
  488.  
  489.    Before you can use a macro, you must "define" it explicitly with the
  490. `#define' command.  `#define' is followed by the name of the macro and
  491. then the code it should be an abbreviation for.  For example,
  492.  
  493.      #define BUFFER_SIZE 1020
  494.  
  495. defines a macro named `BUFFER_SIZE' as an abbreviation for the text
  496. `1020'.  If somewhere after this `#define' command there comes a C
  497. statement of the form
  498.  
  499.      foo = (char *) xmalloc (BUFFER_SIZE);
  500.  
  501. then the C preprocessor will recognize and "expand" the macro
  502. `BUFFER_SIZE', resulting in
  503.  
  504.      foo = (char *) xmalloc (1020);
  505.  
  506.    The use of all upper case for macro names is a standard convention.
  507. Programs are easier to read when it is possible to tell at a glance
  508. which names are macros.
  509.  
  510.    Normally, a macro definition must be a single line, like all C
  511. preprocessor commands.  (You can split a long macro definition
  512. cosmetically with Backslash-Newline.)  There is one exception: Newlines
  513. can be included in the macro definition if within a string or character
  514. constant.  This is because it is not possible for a macro definition to
  515. contain an unbalanced quote character; the definition automatically
  516. extends to include the matching quote character that ends the string or
  517. character constant.  Comments within a macro definition may contain
  518. Newlines, which make no difference since the comments are entirely
  519. replaced with Spaces regardless of their contents.
  520.  
  521.    Aside from the above, there is no restriction on what can go in a
  522. macro body.  Parentheses need not balance.  The body need not resemble
  523. valid C code.  (But if it does not, you may get error messages from the
  524. C compiler when you use the macro.)
  525.  
  526.    The C preprocessor scans your program sequentially, so macro
  527. definitions take effect at the place you write them.  Therefore, the
  528. following input to the C preprocessor
  529.  
  530.      foo = X;
  531.      #define X 4
  532.      bar = X;
  533.  
  534. produces as output
  535.  
  536.      foo = X;
  537.      
  538.      bar = 4;
  539.  
  540.    After the preprocessor expands a macro name, the macro's definition
  541. body is appended to the front of the remaining input, and the check for
  542. macro calls continues.  Therefore, the macro body can contain calls to
  543. other macros.  For example, after
  544.  
  545.      #define BUFSIZE 1020
  546.      #define TABLESIZE BUFSIZE
  547.  
  548. the name `TABLESIZE' when used in the program would go through two
  549. stages of expansion, resulting ultimately in `1020'.
  550.  
  551.    This is not at all the same as defining `TABLESIZE' to be `1020'.
  552. The `#define' for `TABLESIZE' uses exactly the body you specify--in
  553. this case, `BUFSIZE'--and does not check to see whether it too is the
  554. name of a macro.  It's only when you *use* `TABLESIZE' that the result
  555. of its expansion is checked for more macro names.  *Note Cascaded
  556. Macros::.
  557.  
  558. 
  559. File: cpp.info,  Node: Argument Macros,  Next: Predefined,  Prev: Simple Macros,  Up: Macros
  560.  
  561. Macros with Arguments
  562. ---------------------
  563.  
  564.    A simple macro always stands for exactly the same text, each time it
  565. is used.  Macros can be more flexible when they accept "arguments".
  566. Arguments are fragments of code that you supply each time the macro is
  567. used.  These fragments are included in the expansion of the macro
  568. according to the directions in the macro definition.  A macro that
  569. accepts arguments is called a "function-like macro" because the syntax
  570. for using it looks like a function call.
  571.  
  572.    To define a macro that uses arguments, you write a `#define' command
  573. with a list of "argument names" in parentheses after the name of the
  574. macro.  The argument names may be any valid C identifiers, separated by
  575. commas and optionally whitespace.  The open-parenthesis must follow the
  576. macro name immediately, with no space in between.
  577.  
  578.    For example, here is a macro that computes the minimum of two numeric
  579. values, as it is defined in many C programs:
  580.  
  581.      #define min(X, Y)  ((X) < (Y) ? (X) : (Y))
  582.  
  583. (This is not the best way to define a "minimum" macro in GNU C.  *Note
  584. Side Effects::, for more information.)
  585.  
  586.    To use a macro that expects arguments, you write the name of the
  587. macro followed by a list of "actual arguments" in parentheses,
  588. separated by commas.  The number of actual arguments you give must
  589. match the number of arguments the macro expects.   Examples of use of
  590. the macro `min' include `min (1, 2)' and `min (x + 28, *p)'.
  591.  
  592.    The expansion text of the macro depends on the arguments you use.
  593. Each of the argument names of the macro is replaced, throughout the
  594. macro definition, with the corresponding actual argument.  Using the
  595. same macro `min' defined above, `min (1, 2)' expands into
  596.  
  597.      ((1) < (2) ? (1) : (2))
  598.  
  599. where `1' has been substituted for `X' and `2' for `Y'.
  600.  
  601.    Likewise, `min (x + 28, *p)' expands into
  602.  
  603.      ((x + 28) < (*p) ? (x + 28) : (*p))
  604.  
  605.    Parentheses in the actual arguments must balance; a comma within
  606. parentheses does not end an argument.  However, there is no requirement
  607. for brackets or braces to balance, and they do not prevent a comma from
  608. separating arguments.  Thus,
  609.  
  610.      macro (array[x = y, x + 1])
  611.  
  612. passes two arguments to `macro': `array[x = y' and `x + 1]'.  If you
  613. want to supply `array[x = y, x + 1]' as an argument, you must write it
  614. as `array[(x = y, x + 1)]', which is equivalent C code.
  615.  
  616.    After the actual arguments are substituted into the macro body, the
  617. entire result is appended to the front of the remaining input, and the
  618. check for macro calls continues.  Therefore, the actual arguments can
  619. contain calls to other macros, either with or without arguments, or
  620. even to the same macro.  The macro body can also contain calls to other
  621. macros.  For example, `min (min (a, b), c)' expands into this text:
  622.  
  623.      ((((a) < (b) ? (a) : (b))) < (c)
  624.       ? (((a) < (b) ? (a) : (b)))
  625.       : (c))
  626.  
  627. (Line breaks shown here for clarity would not actually be generated.)
  628.  
  629.    If a macro `foo' takes one argument, and you want to supply an empty
  630. argument, you must write at least some whitespace between the
  631. parentheses, like this: `foo ( )'.  Just `foo ()' is providing no
  632. arguments, which is an error if `foo' expects an argument.  But `foo0
  633. ()' is the correct way to call a macro defined to take zero arguments,
  634. like this:
  635.  
  636.      #define foo0() ...
  637.  
  638.    If you use the macro name followed by something other than an
  639. open-parenthesis (after ignoring any spaces, tabs and comments that
  640. follow), it is not a call to the macro, and the preprocessor does not
  641. change what you have written.  Therefore, it is possible for the same
  642. name to be a variable or function in your program as well as a macro,
  643. and you can choose in each instance whether to refer to the macro (if
  644. an actual argument list follows) or the variable or function (if an
  645. argument list does not follow).
  646.  
  647.    Such dual use of one name could be confusing and should be avoided
  648. except when the two meanings are effectively synonymous: that is, when
  649. the name is both a macro and a function and the two have similar
  650. effects.  You can think of the name simply as a function; use of the
  651. name for purposes other than calling it (such as, to take the address)
  652. will refer to the function, while calls will expand the macro and
  653. generate better but equivalent code.  For example, you can use a
  654. function named `min' in the same source file that defines the macro.
  655. If you write `&min' with no argument list, you refer to the function.
  656. If you write `min (x, bb)', with an argument list, the macro is
  657. expanded.  If you write `(min) (a, bb)', where the name `min' is not
  658. followed by an open-parenthesis, the macro is not expanded, so you wind
  659. up with a call to the function `min'.
  660.  
  661.    You may not define the same name as both a simple macro and a macro
  662. with arguments.
  663.  
  664.    In the definition of a macro with arguments, the list of argument
  665. names must follow the macro name immediately with no space in between.
  666. If there is a space after the macro name, the macro is defined as
  667. taking no arguments, and all the rest of the line is taken to be the
  668. expansion.  The reason for this is that it is often useful to define a
  669. macro that takes no arguments and whose definition begins with an
  670. identifier in parentheses.  This rule about spaces makes it possible
  671. for you to do either this:
  672.  
  673.      #define FOO(x) - 1 / (x)
  674.  
  675. (which defines `FOO' to take an argument and expand into minus the
  676. reciprocal of that argument) or this:
  677.  
  678.      #define BAR (x) - 1 / (x)
  679.  
  680. (which defines `BAR' to take no argument and always expand into `(x) -
  681. 1 / (x)').
  682.  
  683.    Note that the *uses* of a macro with arguments can have spaces before
  684. the left parenthesis; it's the *definition* where it matters whether
  685. there is a space.
  686.  
  687. 
  688. File: cpp.info,  Node: Predefined,  Next: Stringification,  Prev: Argument Macros,  Up: Macros
  689.  
  690. Predefined Macros
  691. -----------------
  692.  
  693.    Several simple macros are predefined.  You can use them without
  694. giving definitions for them.  They fall into two classes: standard
  695. macros and system-specific macros.
  696.  
  697. * Menu:
  698.  
  699. * Standard Predefined::     Standard predefined macros.
  700. * Nonstandard Predefined::  Nonstandard predefined macros.
  701.  
  702. 
  703. File: cpp.info,  Node: Standard Predefined,  Next: Nonstandard Predefined,  Prev: Predefined,  Up: Predefined
  704.  
  705. Standard Predefined Macros
  706. ..........................
  707.  
  708.    The standard predefined macros are available with the same meanings
  709. regardless of the machine or operating system on which you are using
  710. GNU C.  Their names all start and end with double underscores.  Those
  711. preceding `__GNUC__' in this table are standardized by ANSI C; the rest
  712. are GNU C extensions.
  713.  
  714. `__FILE__'
  715.      This macro expands to the name of the current input file, in the
  716.      form of a C string constant.  The precise name returned is the one
  717.      that was specified in `#include' or as the input file name
  718.      argument.
  719.  
  720. `__LINE__'
  721.      This macro expands to the current input line number, in the form
  722.      of a decimal integer constant.  While we call it a predefined
  723.      macro, it's a pretty strange macro, since its "definition" changes
  724.      with each new line of source code.
  725.  
  726.      This and `__FILE__' are useful in generating an error message to
  727.      report an inconsistency detected by the program; the message can
  728.      state the source line at which the inconsistency was detected.
  729.      For example,
  730.  
  731.           fprintf (stderr, "Internal error: "
  732.                            "negative string length "
  733.                            "%d at %s, line %d.",
  734.                    length, __FILE__, __LINE__);
  735.  
  736.      A `#include' command changes the expansions of `__FILE__' and
  737.      `__LINE__' to correspond to the included file.  At the end of that
  738.      file, when processing resumes on the input file that contained the
  739.      `#include' command, the expansions of `__FILE__' and `__LINE__'
  740.      revert to the values they had before the `#include' (but
  741.      `__LINE__' is then incremented by one as processing moves to the
  742.      line after the `#include').
  743.  
  744.      The expansions of both `__FILE__' and `__LINE__' are altered if a
  745.      `#line' command is used.  *Note Combining Sources::.
  746.  
  747. `__INCLUDE_LEVEL__'
  748.      This macro expands to a decimal integer constant that represents
  749.      the depth of nesting in include files.  The value of this macro is
  750.      incremented on every `#include' command and decremented at every
  751.      end of file.  For input files specified by command line arguments,
  752.      the nesting level is zero.
  753.  
  754. `__DATE__'
  755.      This macro expands to a string constant that describes the date on
  756.      which the preprocessor is being run.  The string constant contains
  757.      eleven characters and looks like `"Jan 29 1987"' or `"Apr 1 1905"'.
  758.  
  759. `__TIME__'
  760.      This macro expands to a string constant that describes the time at
  761.      which the preprocessor is being run.  The string constant contains
  762.      eight characters and looks like `"23:59:01"'.
  763.  
  764. `__STDC__'
  765.      This macro expands to the constant 1, to signify that this is ANSI
  766.      Standard C.  (Whether that is actually true depends on what C
  767.      compiler will operate on the output from the preprocessor.)
  768.  
  769. `__GNUC__'
  770.      This macro is defined if and only if this is GNU C.  This macro is
  771.      defined only when the entire GNU C compiler is in use; if you
  772.      invoke the preprocessor directly, `__GNUC__' is undefined.  The
  773.      value identifies the major version number of GNU CC (`1' for GNU CC
  774.      version 1, which is now obsolete, and `2' for version 2).
  775.  
  776. `__GNUG__'
  777.      The GNU C compiler defines this when the compilation language is
  778.      C++; use `__GNUG__' to distinguish between GNU C and GNU C++.
  779.  
  780. `__cplusplus'
  781.      The draft ANSI standard for C++ used to require predefining this
  782.      variable.  Though it is no longer required, GNU C++ continues to
  783.      define it, as do other popular C++ compilers.  You can use
  784.      `__cplusplus' to test whether a header is compiled by a C compiler
  785.      or a C++ compiler.
  786.  
  787. `__STRICT_ANSI__'
  788.      This macro is defined if and only if the `-ansi' switch was
  789.      specified when GNU C was invoked.  Its definition is the null
  790.      string.  This macro exists primarily to direct certain GNU header
  791.      files not to define certain traditional Unix constructs which are
  792.      incompatible with ANSI C.
  793.  
  794. `__BASE_FILE__'
  795.      This macro expands to the name of the main input file, in the form
  796.      of a C string constant.  This is the source file that was specified
  797.      as an argument when the C compiler was invoked.
  798.  
  799. `__VERSION__'
  800.      This macro expands to a string which describes the version number
  801.      of GNU C.  The string is normally a sequence of decimal numbers
  802.      separated by periods, such as `"2.6.0"'.  The only reasonable use
  803.      of this macro is to incorporate it into a string constant.
  804.  
  805. `__OPTIMIZE__'
  806.      This macro is defined in optimizing compilations.  It causes
  807.      certain GNU header files to define alternative macro definitions
  808.      for some system library functions.  It is unwise to refer to or
  809.      test the definition of this macro unless you make very sure that
  810.      programs will execute with the same effect regardless.
  811.  
  812. `__CHAR_UNSIGNED__'
  813.      This macro is defined if and only if the data type `char' is
  814.      unsigned on the target machine.  It exists to cause the standard
  815.      header file `limit.h' to work correctly.  It is bad practice to
  816.      refer to this macro yourself; instead, refer to the standard
  817.      macros defined in `limit.h'.  The preprocessor uses this macro to
  818.      determine whether or not to sign-extend large character constants
  819.      written in octal; see *Note The `#if' Command: #if Command.
  820.  
  821. 
  822. File: cpp.info,  Node: Nonstandard Predefined,  Prev: Standard Predefined,  Up: Predefined
  823.  
  824. Nonstandard Predefined Macros
  825. .............................
  826.  
  827.    The C preprocessor normally has several predefined macros that vary
  828. between machines because their purpose is to indicate what type of
  829. system and machine is in use.  This manual, being for all systems and
  830. machines, cannot tell you exactly what their names are; instead, we
  831. offer a list of some typical ones.  You can use `cpp -dM' to see the
  832. values of predefined macros; see *Note Invocation::.
  833.  
  834.    Some nonstandard predefined macros describe the operating system in
  835. use, with more or less specificity.  For example,
  836.  
  837. `unix'
  838.      `unix' is normally predefined on all Unix systems.
  839.  
  840. `BSD'
  841.      `BSD' is predefined on recent versions of Berkeley Unix (perhaps
  842.      only in version 4.3).
  843.  
  844.    Other nonstandard predefined macros describe the kind of CPU, with
  845. more or less specificity.  For example,
  846.  
  847. `vax'
  848.      `vax' is predefined on Vax computers.
  849.  
  850. `mc68000'
  851.      `mc68000' is predefined on most computers whose CPU is a Motorola
  852.      68000, 68010 or 68020.
  853.  
  854. `m68k'
  855.      `m68k' is also predefined on most computers whose CPU is a 68000,
  856.      68010 or 68020; however, some makers use `mc68000' and some use
  857.      `m68k'.  Some predefine both names.  What happens in GNU C depends
  858.      on the system you are using it on.
  859.  
  860. `M68020'
  861.      `M68020' has been observed to be predefined on some systems that
  862.      use 68020 CPUs--in addition to `mc68000' and `m68k', which are
  863.      less specific.
  864.  
  865. `_AM29K'
  866. `_AM29000'
  867.      Both `_AM29K' and `_AM29000' are predefined for the AMD 29000 CPU
  868.      family.
  869.  
  870. `ns32000'
  871.      `ns32000' is predefined on computers which use the National
  872.      Semiconductor 32000 series CPU.
  873.  
  874.    Yet other nonstandard predefined macros describe the manufacturer of
  875. the system.  For example,
  876.  
  877. `sun'
  878.      `sun' is predefined on all models of Sun computers.
  879.  
  880. `pyr'
  881.      `pyr' is predefined on all models of Pyramid computers.
  882.  
  883. `sequent'
  884.      `sequent' is predefined on all models of Sequent computers.
  885.  
  886.    These predefined symbols are not only nonstandard, they are contrary
  887. to the ANSI standard because their names do not start with underscores.
  888. Therefore, the option `-ansi' inhibits the definition of these symbols.
  889.  
  890.    This tends to make `-ansi' useless, since many programs depend on the
  891. customary nonstandard predefined symbols.  Even system header files
  892. check them and will generate incorrect declarations if they do not find
  893. the names that are expected.  You might think that the header files
  894. supplied for the Uglix computer would not need to test what machine
  895. they are running on, because they can simply assume it is the Uglix;
  896. but often they do, and they do so using the customary names.  As a
  897. result, very few C programs will compile with `-ansi'.  We intend to
  898. avoid such problems on the GNU system.
  899.  
  900.    What, then, should you do in an ANSI C program to test the type of
  901. machine it will run on?
  902.  
  903.    GNU C offers a parallel series of symbols for this purpose, whose
  904. names are made from the customary ones by adding `__' at the beginning
  905. and end.  Thus, the symbol `__vax__' would be available on a Vax, and
  906. so on.
  907.  
  908.    The set of nonstandard predefined names in the GNU C preprocessor is
  909. controlled (when `cpp' is itself compiled) by the macro
  910. `CPP_PREDEFINES', which should be a string containing `-D' options,
  911. separated by spaces.  For example, on the Sun 3, we use the following
  912. definition:
  913.  
  914.      #define CPP_PREDEFINES "-Dmc68000 -Dsun -Dunix -Dm68k"
  915.  
  916. This macro is usually specified in `tm.h'.
  917.  
  918. 
  919. File: cpp.info,  Node: Stringification,  Next: Concatenation,  Prev: Predefined,  Up: Macros
  920.  
  921. Stringification
  922. ---------------
  923.  
  924.    "Stringification" means turning a code fragment into a string
  925. constant whose contents are the text for the code fragment.  For
  926. example, stringifying `foo (z)' results in `"foo (z)"'.
  927.  
  928.    In the C preprocessor, stringification is an option available when
  929. macro arguments are substituted into the macro definition.  In the body
  930. of the definition, when an argument name appears, the character `#'
  931. before the name specifies stringification of the corresponding actual
  932. argument when it is substituted at that point in the definition.  The
  933. same argument may be substituted in other places in the definition
  934. without stringification if the argument name appears in those places
  935. with no `#'.
  936.  
  937.    Here is an example of a macro definition that uses stringification:
  938.  
  939.      #define WARN_IF(EXP) \
  940.      do { if (EXP) \
  941.              fprintf (stderr, "Warning: " #EXP "\n"); } \
  942.      while (0)
  943.  
  944. Here the actual argument for `EXP' is substituted once as given, into
  945. the `if' statement, and once as stringified, into the argument to
  946. `fprintf'.  The `do' and `while (0)' are a kludge to make it possible
  947. to write `WARN_IF (ARG);', which the resemblance of `WARN_IF' to a
  948. function would make C programmers want to do; see *Note Swallow
  949. Semicolon::.
  950.  
  951.    The stringification feature is limited to transforming one macro
  952. argument into one string constant: there is no way to combine the
  953. argument with other text and then stringify it all together.  But the
  954. example above shows how an equivalent result can be obtained in ANSI
  955. Standard C using the feature that adjacent string constants are
  956. concatenated as one string constant.  The preprocessor stringifies the
  957. actual value of `EXP' into a separate string constant, resulting in
  958. text like
  959.  
  960.      do { if (x == 0) \
  961.              fprintf (stderr, "Warning: " "x == 0" "\n"); } \
  962.      while (0)
  963.  
  964. but the C compiler then sees three consecutive string constants and
  965. concatenates them into one, producing effectively
  966.  
  967.      do { if (x == 0) \
  968.              fprintf (stderr, "Warning: x == 0\n"); } \
  969.      while (0)
  970.  
  971.    Stringification in C involves more than putting doublequote
  972. characters around the fragment; it is necessary to put backslashes in
  973. front of all doublequote characters, and all backslashes in string and
  974. character constants, in order to get a valid C string constant with the
  975. proper contents.  Thus, stringifying `p = "foo\n";' results in `"p =
  976. \"foo\\n\";"'.  However, backslashes that are not inside of string or
  977. character constants are not duplicated: `\n' by itself stringifies to
  978. `"\n"'.
  979.  
  980.    Whitespace (including comments) in the text being stringified is
  981. handled according to precise rules.  All leading and trailing
  982. whitespace is ignored.  Any sequence of whitespace in the middle of the
  983. text is converted to a single space in the stringified result.
  984.  
  985. 
  986. File: cpp.info,  Node: Concatenation,  Next: Undefining,  Prev: Stringification,  Up: Macros
  987.  
  988. Concatenation
  989. -------------
  990.  
  991.    "Concatenation" means joining two strings into one.  In the context
  992. of macro expansion, concatenation refers to joining two lexical units
  993. into one longer one.  Specifically, an actual argument to the macro can
  994. be concatenated with another actual argument or with fixed text to
  995. produce a longer name.  The longer name might be the name of a function,
  996. variable or type, or a C keyword; it might even be the name of another
  997. macro, in which case it will be expanded.
  998.  
  999.    When you define a macro, you request concatenation with the special
  1000. operator `##' in the macro body.  When the macro is called, after
  1001. actual arguments are substituted, all `##' operators are deleted, and
  1002. so is any whitespace next to them (including whitespace that was part
  1003. of an actual argument).  The result is to concatenate the syntactic
  1004. tokens on either side of the `##'.
  1005.  
  1006.    Consider a C program that interprets named commands.  There probably
  1007. needs to be a table of commands, perhaps an array of structures
  1008. declared as follows:
  1009.  
  1010.      struct command
  1011.      {
  1012.        char *name;
  1013.        void (*function) ();
  1014.      };
  1015.      
  1016.      struct command commands[] =
  1017.      {
  1018.        { "quit", quit_command},
  1019.        { "help", help_command},
  1020.        ...
  1021.      };
  1022.  
  1023.    It would be cleaner not to have to give each command name twice,
  1024. once in the string constant and once in the function name.  A macro
  1025. which takes the name of a command as an argument can make this
  1026. unnecessary.  The string constant can be created with stringification,
  1027. and the function name by concatenating the argument with `_command'.
  1028. Here is how it is done:
  1029.  
  1030.      #define COMMAND(NAME)  { #NAME, NAME ## _command }
  1031.      
  1032.      struct command commands[] =
  1033.      {
  1034.        COMMAND (quit),
  1035.        COMMAND (help),
  1036.        ...
  1037.      };
  1038.  
  1039.    The usual case of concatenation is concatenating two names (or a
  1040. name and a number) into a longer name.  But this isn't the only valid
  1041. case.  It is also possible to concatenate two numbers (or a number and
  1042. a name, such as `1.5' and `e3') into a number.  Also, multi-character
  1043. operators such as `+=' can be formed by concatenation.  In some cases
  1044. it is even possible to piece together a string constant.  However, two
  1045. pieces of text that don't together form a valid lexical unit cannot be
  1046. concatenated.  For example, concatenation with `x' on one side and `+'
  1047. on the other is not meaningful because those two characters can't fit
  1048. together in any lexical unit of C.  The ANSI standard says that such
  1049. attempts at concatenation are undefined, but in the GNU C preprocessor
  1050. it is well defined: it puts the `x' and `+' side by side with no
  1051. particular special results.
  1052.  
  1053.    Keep in mind that the C preprocessor converts comments to whitespace
  1054. before macros are even considered.  Therefore, you cannot create a
  1055. comment by concatenating `/' and `*': the `/*' sequence that starts a
  1056. comment is not a lexical unit, but rather the beginning of a "long"
  1057. space character.  Also, you can freely use comments next to a `##' in a
  1058. macro definition, or in actual arguments that will be concatenated,
  1059. because the comments will be converted to spaces at first sight, and
  1060. concatenation will later discard the spaces.
  1061.  
  1062. 
  1063. File: cpp.info,  Node: Undefining,  Next: Redefining,  Prev: Concatenation,  Up: Macros
  1064.  
  1065. Undefining Macros
  1066. -----------------
  1067.  
  1068.    To "undefine" a macro means to cancel its definition.  This is done
  1069. with the `#undef' command.  `#undef' is followed by the macro name to
  1070. be undefined.
  1071.  
  1072.    Like definition, undefinition occurs at a specific point in the
  1073. source file, and it applies starting from that point.  The name ceases
  1074. to be a macro name, and from that point on it is treated by the
  1075. preprocessor as if it had never been a macro name.
  1076.  
  1077.    For example,
  1078.  
  1079.      #define FOO 4
  1080.      x = FOO;
  1081.      #undef FOO
  1082.      x = FOO;
  1083.  
  1084. expands into
  1085.  
  1086.      x = 4;
  1087.      
  1088.      x = FOO;
  1089.  
  1090. In this example, `FOO' had better be a variable or function as well as
  1091. (temporarily) a macro, in order for the result of the expansion to be
  1092. valid C code.
  1093.  
  1094.    The same form of `#undef' command will cancel definitions with
  1095. arguments or definitions that don't expect arguments.  The `#undef'
  1096. command has no effect when used on a name not currently defined as a
  1097. macro.
  1098.  
  1099. 
  1100. File: cpp.info,  Node: Redefining,  Next: Macro Pitfalls,  Prev: Undefining,  Up: Macros
  1101.  
  1102. Redefining Macros
  1103. -----------------
  1104.  
  1105.    "Redefining" a macro means defining (with `#define') a name that is
  1106. already defined as a macro.
  1107.  
  1108.    A redefinition is trivial if the new definition is transparently
  1109. identical to the old one.  You probably wouldn't deliberately write a
  1110. trivial redefinition, but they can happen automatically when a header
  1111. file is included more than once (*note Header Files::.), so they are
  1112. accepted silently and without effect.
  1113.  
  1114.    Nontrivial redefinition is considered likely to be an error, so it
  1115. provokes a warning message from the preprocessor.  However, sometimes it
  1116. is useful to change the definition of a macro in mid-compilation.  You
  1117. can inhibit the warning by undefining the macro with `#undef' before the
  1118. second definition.
  1119.  
  1120.    In order for a redefinition to be trivial, the new definition must
  1121. exactly match the one already in effect, with two possible exceptions:
  1122.  
  1123.    * Whitespace may be added or deleted at the beginning or the end.
  1124.  
  1125.    * Whitespace may be changed in the middle (but not inside strings).
  1126.      However, it may not be eliminated entirely, and it may not be added
  1127.      where there was no whitespace at all.
  1128.  
  1129.    Recall that a comment counts as whitespace.
  1130.  
  1131. 
  1132. File: cpp.info,  Node: Macro Pitfalls,  Prev: Redefining,  Up: Macros
  1133.  
  1134. Pitfalls and Subtleties of Macros
  1135. ---------------------------------
  1136.  
  1137.    In this section we describe some special rules that apply to macros
  1138. and macro expansion, and point out certain cases in which the rules have
  1139. counterintuitive consequences that you must watch out for.
  1140.  
  1141. * Menu:
  1142.  
  1143. * Misnesting::        Macros can contain unmatched parentheses.
  1144. * Macro Parentheses:: Why apparently superfluous parentheses
  1145.                          may be necessary to avoid incorrect grouping.
  1146. * Swallow Semicolon:: Macros that look like functions
  1147.                          but expand into compound statements.
  1148. * Side Effects::      Unsafe macros that cause trouble when
  1149.                          arguments contain side effects.
  1150. * Self-Reference::    Macros whose definitions use the macros' own names.
  1151. * Argument Prescan::  Actual arguments are checked for macro calls
  1152.                          before they are substituted.
  1153. * Cascaded Macros::   Macros whose definitions use other macros.
  1154. * Newlines in Args::  Sometimes line numbers get confused.
  1155.  
  1156. 
  1157. File: cpp.info,  Node: Misnesting,  Next: Macro Parentheses,  Prev: Macro Pitfalls,  Up: Macro Pitfalls
  1158.  
  1159. Improperly Nested Constructs
  1160. ............................
  1161.  
  1162.    Recall that when a macro is called with arguments, the arguments are
  1163. substituted into the macro body and the result is checked, together with
  1164. the rest of the input file, for more macro calls.
  1165.  
  1166.    It is possible to piece together a macro call coming partially from
  1167. the macro body and partially from the actual arguments.  For example,
  1168.  
  1169.      #define double(x) (2*(x))
  1170.      #define call_with_1(x) x(1)
  1171.  
  1172. would expand `call_with_1 (double)' into `(2*(1))'.
  1173.  
  1174.    Macro definitions do not have to have balanced parentheses.  By
  1175. writing an unbalanced open parenthesis in a macro body, it is possible
  1176. to create a macro call that begins inside the macro body but ends
  1177. outside of it.  For example,
  1178.  
  1179.      #define strange(file) fprintf (file, "%s %d",
  1180.      ...
  1181.      strange(stderr) p, 35)
  1182.  
  1183. This bizarre example expands to `fprintf (stderr, "%s %d", p, 35)'!
  1184.  
  1185.