home *** CD-ROM | disk | FTP | other *** search
/ Whiteline: Alpha / Whiteline Alpha.iso / progtool / c / gcc / gcc258s.zoo / cpp.info-2 < prev    next >
Encoding:
GNU Info File  |  1993-10-16  |  48.6 KB  |  1,242 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. File: cpp.info,  Node: Swallow Semicolon,  Next: Side Effects,  Prev: Macro Parentheses,  Up: Macro Pitfalls
  22.  
  23. Swallowing the Semicolon
  24. ........................
  25.  
  26.    Often it is desirable to define a macro that expands into a compound
  27. statement.  Consider, for example, the following macro, that advances a
  28. pointer (the argument `p' says where to find it) across whitespace
  29. characters:
  30.  
  31.      #define SKIP_SPACES (p, limit)  \
  32.      { register char *lim = (limit); \
  33.        while (p != lim) {            \
  34.          if (*p++ != ' ') {          \
  35.            p--; break; }}}
  36.  
  37. Here Backslash-Newline is used to split the macro definition, which must
  38. be a single line, so that it resembles the way such C code would be
  39. laid out if not part of a macro definition.
  40.  
  41.    A call to this macro might be `SKIP_SPACES (p, lim)'.  Strictly
  42. speaking, the call expands to a compound statement, which is a complete
  43. statement with no need for a semicolon to end it.  But it looks like a
  44. function call.  So it minimizes confusion if you can use it like a
  45. function call, writing a semicolon afterward, as in `SKIP_SPACES (p,
  46. lim);'
  47.  
  48.    But this can cause trouble before `else' statements, because the
  49. semicolon is actually a null statement.  Suppose you write
  50.  
  51.      if (*p != 0)
  52.        SKIP_SPACES (p, lim);
  53.      else ...
  54.  
  55. The presence of two statements--the compound statement and a null
  56. statement--in between the `if' condition and the `else' makes invalid C
  57. code.
  58.  
  59.    The definition of the macro `SKIP_SPACES' can be altered to solve
  60. this problem, using a `do ... while' statement.  Here is how:
  61.  
  62.      #define SKIP_SPACES (p, limit)     \
  63.      do { register char *lim = (limit); \
  64.           while (p != lim) {            \
  65.             if (*p++ != ' ') {          \
  66.               p--; break; }}}           \
  67.      while (0)
  68.  
  69.    Now `SKIP_SPACES (p, lim);' expands into
  70.  
  71.      do {...} while (0);
  72.  
  73. which is one statement.
  74.  
  75. File: cpp.info,  Node: Side Effects,  Next: Self-Reference,  Prev: Swallow Semicolon,  Up: Macro Pitfalls
  76.  
  77. Duplication of Side Effects
  78. ...........................
  79.  
  80.    Many C programs define a macro `min', for "minimum", like this:
  81.  
  82.      #define min(X, Y)  ((X) < (Y) ? (X) : (Y))
  83.  
  84.    When you use this macro with an argument containing a side effect,
  85. as shown here,
  86.  
  87.      next = min (x + y, foo (z));
  88.  
  89. it expands as follows:
  90.  
  91.      next = ((x + y) < (foo (z)) ? (x + y) : (foo (z)));
  92.  
  93. where `x + y' has been substituted for `X' and `foo (z)' for `Y'.
  94.  
  95.    The function `foo' is used only once in the statement as it appears
  96. in the program, but the expression `foo (z)' has been substituted twice
  97. into the macro expansion.  As a result, `foo' might be called two times
  98. when the statement is executed.  If it has side effects or if it takes
  99. a long time to compute, the results might not be what you intended.  We
  100. say that `min' is an "unsafe" macro.
  101.  
  102.    The best solution to this problem is to define `min' in a way that
  103. computes the value of `foo (z)' only once.  The C language offers no
  104. standard way to do this, but it can be done with GNU C extensions as
  105. follows:
  106.  
  107.      #define min(X, Y)                     \
  108.      ({ typeof (X) __x = (X), __y = (Y);   \
  109.         (__x < __y) ? __x : __y; })
  110.  
  111.    If you do not wish to use GNU C extensions, the only solution is to
  112. be careful when *using* the macro `min'.  For example, you can
  113. calculate the value of `foo (z)', save it in a variable, and use that
  114. variable in `min':
  115.  
  116.      #define min(X, Y)  ((X) < (Y) ? (X) : (Y))
  117.      ...
  118.      {
  119.        int tem = foo (z);
  120.        next = min (x + y, tem);
  121.      }
  122.  
  123. (where we assume that `foo' returns type `int').
  124.  
  125. File: cpp.info,  Node: Self-Reference,  Next: Argument Prescan,  Prev: Side Effects,  Up: Macro Pitfalls
  126.  
  127. Self-Referential Macros
  128. .......................
  129.  
  130.    A "self-referential" macro is one whose name appears in its
  131. definition.  A special feature of ANSI Standard C is that the
  132. self-reference is not considered a macro call.  It is passed into the
  133. preprocessor output unchanged.
  134.  
  135.    Let's consider an example:
  136.  
  137.      #define foo (4 + foo)
  138.  
  139. where `foo' is also a variable in your program.
  140.  
  141.    Following the ordinary rules, each reference to `foo' will expand
  142. into `(4 + foo)'; then this will be rescanned and will expand into `(4
  143. + (4 + foo))'; and so on until it causes a fatal error (memory full) in
  144. the preprocessor.
  145.  
  146.    However, the special rule about self-reference cuts this process
  147. short after one step, at `(4 + foo)'.  Therefore, this macro definition
  148. has the possibly useful effect of causing the program to add 4 to the
  149. value of `foo' wherever `foo' is referred to.
  150.  
  151.    In most cases, it is a bad idea to take advantage of this feature.  A
  152. person reading the program who sees that `foo' is a variable will not
  153. expect that it is a macro as well.  The reader will come across the
  154. identifier `foo' in the program and think its value should be that of
  155. the variable `foo', whereas in fact the value is four greater.
  156.  
  157.    The special rule for self-reference applies also to "indirect"
  158. self-reference.  This is the case where a macro X expands to use a
  159. macro `y', and the expansion of `y' refers to the macro `x'.  The
  160. resulting reference to `x' comes indirectly from the expansion of `x',
  161. so it is a self-reference and is not further expanded.  Thus, after
  162.  
  163.      #define x (4 + y)
  164.      #define y (2 * x)
  165.  
  166. `x' would expand into `(4 + (2 * x))'.  Clear?
  167.  
  168.    But suppose `y' is used elsewhere, not from the definition of `x'.
  169. Then the use of `x' in the expansion of `y' is not a self-reference
  170. because `x' is not "in progress".  So it does expand.  However, the
  171. expansion of `x' contains a reference to `y', and that is an indirect
  172. self-reference now because `y' is "in progress".  The result is that
  173. `y' expands to `(2 * (4 + y))'.
  174.  
  175.    It is not clear that this behavior would ever be useful, but it is
  176. specified by the ANSI C standard, so you may need to understand it.
  177.  
  178. File: cpp.info,  Node: Argument Prescan,  Next: Cascaded Macros,  Prev: Self-Reference,  Up: Macro Pitfalls
  179.  
  180. Separate Expansion of Macro Arguments
  181. .....................................
  182.  
  183.    We have explained that the expansion of a macro, including the
  184. substituted actual arguments, is scanned over again for macro calls to
  185. be expanded.
  186.  
  187.    What really happens is more subtle: first each actual argument text
  188. is scanned separately for macro calls.  Then the results of this are
  189. substituted into the macro body to produce the macro expansion, and the
  190. macro expansion is scanned again for macros to expand.
  191.  
  192.    The result is that the actual arguments are scanned *twice* to expand
  193. macro calls in them.
  194.  
  195.    Most of the time, this has no effect.  If the actual argument
  196. contained any macro calls, they are expanded during the first scan.
  197. The result therefore contains no macro calls, so the second scan does
  198. not change it.  If the actual argument were substituted as given, with
  199. no prescan, the single remaining scan would find the same macro calls
  200. and produce the same results.
  201.  
  202.    You might expect the double scan to change the results when a
  203. self-referential macro is used in an actual argument of another macro
  204. (*note Self-Reference::.): the self-referential macro would be expanded
  205. once in the first scan, and a second time in the second scan.  But this
  206. is not what happens.  The self-references that do not expand in the
  207. first scan are marked so that they will not expand in the second scan
  208. either.
  209.  
  210.    The prescan is not done when an argument is stringified or
  211. concatenated.  Thus,
  212.  
  213.      #define str(s) #s
  214.      #define foo 4
  215.      str (foo)
  216.  
  217. expands to `"foo"'.  Once more, prescan has been prevented from having
  218. any noticeable effect.
  219.  
  220.    More precisely, stringification and concatenation use the argument as
  221. written, in un-prescanned form.  The same actual argument would be used
  222. in prescanned form if it is substituted elsewhere without
  223. stringification or concatenation.
  224.  
  225.      #define str(s) #s lose(s)
  226.      #define foo 4
  227.      str (foo)
  228.  
  229.    expands to `"foo" lose(4)'.
  230.  
  231.    You might now ask, "Why mention the prescan, if it makes no
  232. difference?  And why not skip it and make the preprocessor faster?"
  233. The answer is that the prescan does make a difference in three special
  234. cases:
  235.  
  236.    * Nested calls to a macro.
  237.  
  238.    * Macros that call other macros that stringify or concatenate.
  239.  
  240.    * Macros whose expansions contain unshielded commas.
  241.  
  242.    We say that "nested" calls to a macro occur when a macro's actual
  243. argument contains a call to that very macro.  For example, if `f' is a
  244. macro that expects one argument, `f (f (1))' is a nested pair of calls
  245. to `f'.  The desired expansion is made by expanding `f (1)' and
  246. substituting that into the definition of `f'.  The prescan causes the
  247. expected result to happen.  Without the prescan, `f (1)' itself would
  248. be substituted as an actual argument, and the inner use of `f' would
  249. appear during the main scan as an indirect self-reference and would not
  250. be expanded.  Here, the prescan cancels an undesirable side effect (in
  251. the medical, not computational, sense of the term) of the special rule
  252. for self-referential macros.
  253.  
  254.    But prescan causes trouble in certain other cases of nested macro
  255. calls.  Here is an example:
  256.  
  257.      #define foo  a,b
  258.      #define bar(x) lose(x)
  259.      #define lose(x) (1 + (x))
  260.      
  261.      bar(foo)
  262.  
  263. We would like `bar(foo)' to turn into `(1 + (foo))', which would then
  264. turn into `(1 + (a,b))'.  But instead, `bar(foo)' expands into
  265. `lose(a,b)', and you get an error because `lose' requires a single
  266. argument.  In this case, the problem is easily solved by the same
  267. parentheses that ought to be used to prevent misnesting of arithmetic
  268. operations:
  269.  
  270.      #define foo (a,b)
  271.      #define bar(x) lose((x))
  272.  
  273.    The problem is more serious when the operands of the macro are not
  274. expressions; for example, when they are statements.  Then parentheses
  275. are unacceptable because they would make for invalid C code:
  276.  
  277.      #define foo { int a, b; ... }
  278.  
  279. In GNU C you can shield the commas using the `({...})' construct which
  280. turns a compound statement into an expression:
  281.  
  282.      #define foo ({ int a, b; ... })
  283.  
  284.    Or you can rewrite the macro definition to avoid such commas:
  285.  
  286.      #define foo { int a; int b; ... }
  287.  
  288.    There is also one case where prescan is useful.  It is possible to
  289. use prescan to expand an argument and then stringify it--if you use two
  290. levels of macros.  Let's add a new macro `xstr' to the example shown
  291. above:
  292.  
  293.      #define xstr(s) str(s)
  294.      #define str(s) #s
  295.      #define foo 4
  296.      xstr (foo)
  297.  
  298.    This expands into `"4"', not `"foo"'.  The reason for the difference
  299. is that the argument of `xstr' is expanded at prescan (because `xstr'
  300. does not specify stringification or concatenation of the argument).
  301. The result of prescan then forms the actual argument for `str'.  `str'
  302. uses its argument without prescan because it performs stringification;
  303. but it cannot prevent or undo the prescanning already done by `xstr'.
  304.  
  305. File: cpp.info,  Node: Cascaded Macros,  Next: Newlines in Args,  Prev: Argument Prescan,  Up: Macro Pitfalls
  306.  
  307. Cascaded Use of Macros
  308. ......................
  309.  
  310.    A "cascade" of macros is when one macro's body contains a reference
  311. to another macro.  This is very common practice.  For example,
  312.  
  313.      #define BUFSIZE 1020
  314.      #define TABLESIZE BUFSIZE
  315.  
  316.    This is not at all the same as defining `TABLESIZE' to be `1020'.
  317. The `#define' for `TABLESIZE' uses exactly the body you specify--in
  318. this case, `BUFSIZE'--and does not check to see whether it too is the
  319. name of a macro.
  320.  
  321.    It's only when you *use* `TABLESIZE' that the result of its expansion
  322. is checked for more macro names.
  323.  
  324.    This makes a difference if you change the definition of `BUFSIZE' at
  325. some point in the source file.  `TABLESIZE', defined as shown, will
  326. always expand using the definition of `BUFSIZE' that is currently in
  327. effect:
  328.  
  329.      #define BUFSIZE 1020
  330.      #define TABLESIZE BUFSIZE
  331.      #undef BUFSIZE
  332.      #define BUFSIZE 37
  333.  
  334. Now `TABLESIZE' expands (in two stages) to `37'.
  335.  
  336. File: cpp.info,  Node: Newlines in Args,  Prev: Cascaded Macros,  Up: Macro Pitfalls
  337.  
  338. Newlines in Macro Arguments
  339. ---------------------------
  340.  
  341.    Traditional macro processing carries forward all newlines in macro
  342. arguments into the expansion of the macro.  This means that, if some of
  343. the arguments are substituted more than once, or not at all, or out of
  344. order, newlines can be duplicated, lost, or moved around within the
  345. expansion.  If the expansion consists of multiple statements, then the
  346. effect is to distort the line numbers of some of these statements.  The
  347. result can be incorrect line numbers, in error messages or displayed in
  348. a debugger.
  349.  
  350.    The GNU C preprocessor operating in ANSI C mode adjusts appropriately
  351. for multiple use of an argument--the first use expands all the
  352. newlines, and subsequent uses of the same argument produce no newlines.
  353. But even in this mode, it can produce incorrect line numbering if
  354. arguments are used out of order, or not used at all.
  355.  
  356.    Here is an example illustrating this problem:
  357.  
  358.      #define ignore_second_arg(a,b,c) a; c
  359.      
  360.      ignore_second_arg (foo (),
  361.                         ignored (),
  362.                         syntax error);
  363.  
  364. The syntax error triggered by the tokens `syntax error' results in an
  365. error message citing line four, even though the statement text comes
  366. from line five.
  367.  
  368. File: cpp.info,  Node: Conditionals,  Next: Combining Sources,  Prev: Macros,  Up: Top
  369.  
  370. Conditionals
  371. ============
  372.  
  373.    In a macro processor, a "conditional" is a command that allows a part
  374. of the program to be ignored during compilation, on some conditions.
  375. In the C preprocessor, a conditional can test either an arithmetic
  376. expression or whether a name is defined as a macro.
  377.  
  378.    A conditional in the C preprocessor resembles in some ways an `if'
  379. statement in C, but it is important to understand the difference between
  380. them.  The condition in an `if' statement is tested during the execution
  381. of your program.  Its purpose is to allow your program to behave
  382. differently from run to run, depending on the data it is operating on.
  383. The condition in a preprocessor conditional command is tested when your
  384. program is compiled.  Its purpose is to allow different code to be
  385. included in the program depending on the situation at the time of
  386. compilation.
  387.  
  388. * Menu:
  389.  
  390. * Uses: Conditional Uses.       What conditionals are for.
  391. * Syntax: Conditional Syntax.   How conditionals are written.
  392. * Deletion: Deleted Code.       Making code into a comment.
  393. * Macros: Conditionals-Macros.  Why conditionals are used with macros.
  394. * Assertions::                How and why to use assertions.
  395. * Errors: #error Command.       Detecting inconsistent compilation parameters.
  396.  
  397. File: cpp.info,  Node: Conditional Uses,  Next: Conditional Syntax,  Up: Conditionals
  398.  
  399. Why Conditionals are Used
  400. -------------------------
  401.  
  402.    Generally there are three kinds of reason to use a conditional.
  403.  
  404.    * A program may need to use different code depending on the machine
  405.      or operating system it is to run on.  In some cases the code for
  406.      one operating system may be erroneous on another operating system;
  407.      for example, it might refer to library routines that do not exist
  408.      on the other system.  When this happens, it is not enough to avoid
  409.      executing the invalid code: merely having it in the program makes
  410.      it impossible to link the program and run it.  With a preprocessor
  411.      conditional, the offending code can be effectively excised from
  412.      the program when it is not valid.
  413.  
  414.    * You may want to be able to compile the same source file into two
  415.      different programs.  Sometimes the difference between the programs
  416.      is that one makes frequent time-consuming consistency checks on its
  417.      intermediate data while the other does not.
  418.  
  419.    * A conditional whose condition is always false is a good way to
  420.      exclude code from the program but keep it as a sort of comment for
  421.      future reference.
  422.  
  423.    Most simple programs that are intended to run on only one machine
  424. will not need to use preprocessor conditionals.
  425.  
  426. File: cpp.info,  Node: Conditional Syntax,  Next: Deleted Code,  Prev: Conditional Uses,  Up: Conditionals
  427.  
  428. Syntax of Conditionals
  429. ----------------------
  430.  
  431.    A conditional in the C preprocessor begins with a "conditional
  432. command": `#if', `#ifdef' or `#ifndef'.  *Note Conditionals-Macros::,
  433. for information on `#ifdef' and `#ifndef'; only `#if' is explained here.
  434.  
  435. * Menu:
  436.  
  437. * If: #if Command.     Basic conditionals using `#if' and `#endif'.
  438. * Else: #else Command. Including some text if the condition fails.
  439. * Elif: #elif Command. Testing several alternative possibilities.
  440.  
  441. File: cpp.info,  Node: #if Command,  Next: #else Command,  Up: Conditional Syntax
  442.  
  443. The `#if' Command
  444. .................
  445.  
  446.    The `#if' command in its simplest form consists of
  447.  
  448.      #if EXPRESSION
  449.      CONTROLLED TEXT
  450.      #endif /* EXPRESSION */
  451.  
  452.    The comment following the `#endif' is not required, but it is a good
  453. practice because it helps people match the `#endif' to the
  454. corresponding `#if'.  Such comments should always be used, except in
  455. short conditionals that are not nested.  In fact, you can put anything
  456. at all after the `#endif' and it will be ignored by the GNU C
  457. preprocessor, but only comments are acceptable in ANSI Standard C.
  458.  
  459.    EXPRESSION is a C expression of integer type, subject to stringent
  460. restrictions.  It may contain
  461.  
  462.    * Integer constants, which are all regarded as `long' or `unsigned
  463.      long'.
  464.  
  465.    * Character constants, which are interpreted according to the
  466.      character set and conventions of the machine and operating system
  467.      on which the preprocessor is running.  The GNU C preprocessor uses
  468.      the C data type `char' for these character constants; therefore,
  469.      whether some character codes are negative is determined by the C
  470.      compiler used to compile the preprocessor.  If it treats `char' as
  471.      signed, then character codes large enough to set the sign bit will
  472.      be considered negative; otherwise, no character code is considered
  473.      negative.
  474.  
  475.    * Arithmetic operators for addition, subtraction, multiplication,
  476.      division, bitwise operations, shifts, comparisons, and `&&' and
  477.      `||'.
  478.  
  479.    * Identifiers that are not macros, which are all treated as zero(!).
  480.  
  481.    * Macro calls.  All macro calls in the expression are expanded before
  482.      actual computation of the expression's value begins.
  483.  
  484.    Note that `sizeof' operators and `enum'-type values are not allowed.
  485. `enum'-type values, like all other identifiers that are not taken as
  486. macro calls and expanded, are treated as zero.
  487.  
  488.    The CONTROLLED TEXT inside of a conditional can include preprocessor
  489. commands.  Then the commands inside the conditional are obeyed only if
  490. that branch of the conditional succeeds.  The text can also contain
  491. other conditional groups.  However, the `#if' and `#endif' commands
  492. must balance.
  493.  
  494. File: cpp.info,  Node: #else Command,  Next: #elif Command,  Prev: #if Command,  Up: Conditional Syntax
  495.  
  496. The `#else' Command
  497. ...................
  498.  
  499.    The `#else' command can be added to a conditional to provide
  500. alternative text to be used if the condition is false.  This is what it
  501. looks like:
  502.  
  503.      #if EXPRESSION
  504.      TEXT-IF-TRUE
  505.      #else /* Not EXPRESSION */
  506.      TEXT-IF-FALSE
  507.      #endif /* Not EXPRESSION */
  508.  
  509.    If EXPRESSION is nonzero, and thus the TEXT-IF-TRUE is active, then
  510. `#else' acts like a failing conditional and the TEXT-IF-FALSE is
  511. ignored.  Contrariwise, if the `#if' conditional fails, the
  512. TEXT-IF-FALSE is considered included.
  513.  
  514. File: cpp.info,  Node: #elif Command,  Prev: #else Command,  Up: Conditional Syntax
  515.  
  516. The `#elif' Command
  517. ...................
  518.  
  519.    One common case of nested conditionals is used to check for more
  520. than two possible alternatives.  For example, you might have
  521.  
  522.      #if X == 1
  523.      ...
  524.      #else /* X != 1 */
  525.      #if X == 2
  526.      ...
  527.      #else /* X != 2 */
  528.      ...
  529.      #endif /* X != 2 */
  530.      #endif /* X != 1 */
  531.  
  532.    Another conditional command, `#elif', allows this to be abbreviated
  533. as follows:
  534.  
  535.      #if X == 1
  536.      ...
  537.      #elif X == 2
  538.      ...
  539.      #else /* X != 2 and X != 1*/
  540.      ...
  541.      #endif /* X != 2 and X != 1*/
  542.  
  543.    `#elif' stands for "else if".  Like `#else', it goes in the middle
  544. of a `#if'-`#endif' pair and subdivides it; it does not require a
  545. matching `#endif' of its own.  Like `#if', the `#elif' command includes
  546. an expression to be tested.
  547.  
  548.    The text following the `#elif' is processed only if the original
  549. `#if'-condition failed and the `#elif' condition succeeds.  More than
  550. one `#elif' can go in the same `#if'-`#endif' group.  Then the text
  551. after each `#elif' is processed only if the `#elif' condition succeeds
  552. after the original `#if' and any previous `#elif' commands within it
  553. have failed.  `#else' is equivalent to `#elif 1', and `#else' is
  554. allowed after any number of `#elif' commands, but `#elif' may not follow
  555. `#else'.
  556.  
  557. File: cpp.info,  Node: Deleted Code,  Next: Conditionals-Macros,  Prev: Conditional Syntax,  Up: Conditionals
  558.  
  559. Keeping Deleted Code for Future Reference
  560. -----------------------------------------
  561.  
  562.    If you replace or delete a part of the program but want to keep the
  563. old code around as a comment for future reference, the easy way to do
  564. this is to put `#if 0' before it and `#endif' after it.
  565.  
  566.    This works even if the code being turned off contains conditionals,
  567. but they must be entire conditionals (balanced `#if' and `#endif').
  568.  
  569. File: cpp.info,  Node: Conditionals-Macros,  Next: Assertions,  Prev: Deleted Code,  Up: Conditionals
  570.  
  571. Conditionals and Macros
  572. -----------------------
  573.  
  574.    Conditionals are useful in connection with macros or assertions,
  575. because those are the only ways that an expression's value can vary
  576. from one compilation to another.  A `#if' command whose expression uses
  577. no macros or assertions is equivalent to `#if 1' or `#if 0'; you might
  578. as well determine which one, by computing the value of the expression
  579. yourself, and then simplify the program.
  580.  
  581.    For example, here is a conditional that tests the expression
  582. `BUFSIZE == 1020', where `BUFSIZE' must be a macro.
  583.  
  584.      #if BUFSIZE == 1020
  585.        printf ("Large buffers!\n");
  586.      #endif /* BUFSIZE is large */
  587.  
  588.    (Programmers often wish they could test the size of a variable or
  589. data type in `#if', but this does not work.  The preprocessor does not
  590. understand `sizeof', or typedef names, or even the type keywords such
  591. as `int'.)
  592.  
  593.    The special operator `defined' is used in `#if' expressions to test
  594. whether a certain name is defined as a macro.  Either `defined NAME' or
  595. `defined (NAME)' is an expression whose value is 1 if NAME is defined
  596. as macro at the current point in the program, and 0 otherwise.  For the
  597. `defined' operator it makes no difference what the definition of the
  598. macro is; all that matters is whether there is a definition.  Thus, for
  599. example,
  600.  
  601.      #if defined (vax) || defined (ns16000)
  602.  
  603. would include the following code if either of the names `vax' and
  604. `ns16000' is defined as a macro.  You can test the same condition using
  605. assertions (*note Assertions::.), like this:
  606.  
  607.      #if #cpu (vax) || #cpu (ns16000)
  608.  
  609.    If a macro is defined and later undefined with `#undef', subsequent
  610. use of the `defined' operator returns 0, because the name is no longer
  611. defined.  If the macro is defined again with another `#define',
  612. `defined' will recommence returning 1.
  613.  
  614.    Conditionals that test just the definedness of one name are very
  615. common, so there are two special short conditional commands for this
  616. case.
  617.  
  618. `#ifdef NAME'
  619.      is equivalent to `#if defined (NAME)'.
  620.  
  621. `#ifndef NAME'
  622.      is equivalent to `#if ! defined (NAME)'.
  623.  
  624.    Macro definitions can vary between compilations for several reasons.
  625.  
  626.    * Some macros are predefined on each kind of machine.  For example,
  627.      on a Vax, the name `vax' is a predefined macro.  On other
  628.      machines, it would not be defined.
  629.  
  630.    * Many more macros are defined by system header files.  Different
  631.      systems and machines define different macros, or give them
  632.      different values.  It is useful to test these macros with
  633.      conditionals to avoid using a system feature on a machine where it
  634.      is not implemented.
  635.  
  636.    * Macros are a common way of allowing users to customize a program
  637.      for different machines or applications.  For example, the macro
  638.      `BUFSIZE' might be defined in a configuration file for your
  639.      program that is included as a header file in each source file.  You
  640.      would use `BUFSIZE' in a preprocessor conditional in order to
  641.      generate different code depending on the chosen configuration.
  642.  
  643.    * Macros can be defined or undefined with `-D' and `-U' command
  644.      options when you compile the program.  You can arrange to compile
  645.      the same source file into two different programs by choosing a
  646.      macro name to specify which program you want, writing conditionals
  647.      to test whether or how this macro is defined, and then controlling
  648.      the state of the macro with compiler command options.  *Note
  649.      Invocation::.
  650.  
  651.    Assertions are usually predefined, but can be defined with
  652. preprocessor commands or command-line options.
  653.  
  654. File: cpp.info,  Node: Assertions,  Next: #error Command,  Prev: Conditionals-Macros,  Up: Conditionals
  655.  
  656. Assertions
  657. ----------
  658.  
  659.    "Assertions" are a more systematic alternative to macros in writing
  660. conditionals to test what sort of computer or system the compiled
  661. program will run on.  Assertions are usually predefined, but you can
  662. define them with preprocessor commands or command-line options.
  663.  
  664.    The macros traditionally used to describe the type of target are not
  665. classified in any way according to which question they answer; they may
  666. indicate a hardware architecture, a particular hardware model, an
  667. operating system, a particular version of an operating system, or
  668. specific configuration options.  These are jumbled together in a single
  669. namespace.  In contrast, each assertion consists of a named question and
  670. an answer.  The question is usually called the "predicate".  An
  671. assertion looks like this:
  672.  
  673.      #PREDICATE (ANSWER)
  674.  
  675. You must use a properly formed identifier for PREDICATE.  The value of
  676. ANSWER can be any sequence of words; all characters are significant
  677. except for leading and trailing whitespace, and differences in internal
  678. whitespace sequences are ignored.  Thus, `x + y' is different from
  679. `x+y' but equivalent to `x + y'.  `)' is not allowed in an answer.
  680.  
  681.    Here is a conditional to test whether the answer ANSWER is asserted
  682. for the predicate PREDICATE:
  683.  
  684.      #if #PREDICATE (ANSWER)
  685.  
  686. There may be more than one answer asserted for a given predicate.  If
  687. you omit the answer, you can test whether *any* answer is asserted for
  688. PREDICATE:
  689.  
  690.      #if #PREDICATE
  691.  
  692.    Most of the time, the assertions you test will be predefined
  693. assertions.  GNU C provides three predefined predicates: `system',
  694. `cpu', and `machine'.  `system' is for assertions about the type of
  695. software, `cpu' describes the type of computer architecture, and
  696. `machine' gives more information about the computer.  For example, on a
  697. GNU system, the following assertions would be true:
  698.  
  699.      #system (gnu)
  700.      #system (mach)
  701.      #system (mach 3)
  702.      #system (mach 3.SUBVERSION)
  703.      #system (hurd)
  704.      #system (hurd VERSION)
  705.  
  706. and perhaps others.  The alternatives with more or less version
  707. information let you ask more or less detailed questions about the type
  708. of system software.
  709.  
  710.    On a Unix system, you would find `#system (unix)' and perhaps one of:
  711. `#system (aix)', `#system (bsd)', `#system (hpux)', `#system (lynx)',
  712. `#system (mach)', `#system (posix)', `#system (svr3)', `#system
  713. (svr4)', or `#system (xpg4)' with possible version numbers following.
  714.  
  715.    Other values for `system' are `#system (mvs)' and `#system (vms)'.
  716.  
  717.    *Portability note:* Many Unix C compilers provide only one answer
  718. for the `system' assertion: `#system (unix)', if they support
  719. assertions at all.  This is less than useful.
  720.  
  721.    An assertion with a multi-word answer is completely different from
  722. several assertions with individual single-word answers.  For example,
  723. the presence of `system (mach 3.0)' does not mean that `system (3.0)'
  724. is true.  It also does not directly imply `system (mach)', but in GNU
  725. C, that last will normally be asserted as well.
  726.  
  727.    The current list of possible assertion values for `cpu' is: `#cpu
  728. (a29k)', `#cpu (alpha)', `#cpu (arm)', `#cpu (clipper)', `#cpu
  729. (convex)', `#cpu (elxsi)', `#cpu (tron)', `#cpu (h8300)', `#cpu
  730. (i370)', `#cpu (i386)', `#cpu (i860)', `#cpu (i960)', `#cpu (m68k)',
  731. `#cpu (m88k)', `#cpu (mips)', `#cpu (ns32k)', `#cpu (hppa)', `#cpu
  732. (pyr)', `#cpu (ibm032)', `#cpu (rs6000)', `#cpu (sh)', `#cpu (sparc)',
  733. `#cpu (spur)', `#cpu (tahoe)', `#cpu (vax)', `#cpu (we32000)'.
  734.  
  735.    You can create assertions within a C program using `#assert', like
  736. this:
  737.  
  738.      #assert PREDICATE (ANSWER)
  739.  
  740. (Note the absence of a `#' before PREDICATE.)
  741.  
  742.    Each time you do this, you assert a new true answer for PREDICATE.
  743. Asserting one answer does not invalidate previously asserted answers;
  744. they all remain true.  The only way to remove an assertion is with
  745. `#unassert'.  `#unassert' has the same syntax as `#assert'.  You can
  746. also remove all assertions about PREDICATE like this:
  747.  
  748.      #unassert PREDICATE
  749.  
  750.    You can also add or cancel assertions using command options when you
  751. run `gcc' or `cpp'.  *Note Invocation::.
  752.  
  753. File: cpp.info,  Node: #error Command,  Prev: Assertions,  Up: Conditionals
  754.  
  755. The `#error' and `#warning' Commands
  756. ------------------------------------
  757.  
  758.    The command `#error' causes the preprocessor to report a fatal
  759. error.  The rest of the line that follows `#error' is used as the error
  760. message.
  761.  
  762.    You would use `#error' inside of a conditional that detects a
  763. combination of parameters which you know the program does not properly
  764. support.  For example, if you know that the program will not run
  765. properly on a Vax, you might write
  766.  
  767.      #ifdef vax
  768.      #error Won't work on Vaxen.  See comments at get_last_object.
  769.      #endif
  770.  
  771. *Note Nonstandard Predefined::, for why this works.
  772.  
  773.    If you have several configuration parameters that must be set up by
  774. the installation in a consistent way, you can use conditionals to detect
  775. an inconsistency and report it with `#error'.  For example,
  776.  
  777.      #if HASH_TABLE_SIZE % 2 == 0 || HASH_TABLE_SIZE % 3 == 0 \
  778.          || HASH_TABLE_SIZE % 5 == 0
  779.      #error HASH_TABLE_SIZE should not be divisible by a small prime
  780.      #endif
  781.  
  782.    The command `#warning' is like the command `#error', but causes the
  783. preprocessor to issue a warning and continue preprocessing.  The rest of
  784. the line that follows `#warning' is used as the warning message.
  785.  
  786.    You might use `#warning' in obsolete header files, with a message
  787. directing the user to the header file which should be used instead.
  788.  
  789. File: cpp.info,  Node: Combining Sources,  Next: Other Commands,  Prev: Conditionals,  Up: Top
  790.  
  791. Combining Source Files
  792. ======================
  793.  
  794.    One of the jobs of the C preprocessor is to inform the C compiler of
  795. where each line of C code came from: which source file and which line
  796. number.
  797.  
  798.    C code can come from multiple source files if you use `#include';
  799. both `#include' and the use of conditionals and macros can cause the
  800. line number of a line in the preprocessor output to be different from
  801. the line's number in the original source file.  You will appreciate the
  802. value of making both the C compiler (in error messages) and symbolic
  803. debuggers such as GDB use the line numbers in your source file.
  804.  
  805.    The C preprocessor builds on this feature by offering a command by
  806. which you can control the feature explicitly.  This is useful when a
  807. file for input to the C preprocessor is the output from another program
  808. such as the `bison' parser generator, which operates on another file
  809. that is the true source file.  Parts of the output from `bison' are
  810. generated from scratch, other parts come from a standard parser file.
  811. The rest are copied nearly verbatim from the source file, but their
  812. line numbers in the `bison' output are not the same as their original
  813. line numbers.  Naturally you would like compiler error messages and
  814. symbolic debuggers to know the original source file and line number of
  815. each line in the `bison' input.
  816.  
  817.    `bison' arranges this by writing `#line' commands into the output
  818. file.  `#line' is a command that specifies the original line number and
  819. source file name for subsequent input in the current preprocessor input
  820. file.  `#line' has three variants:
  821.  
  822. `#line LINENUM'
  823.      Here LINENUM is a decimal integer constant.  This specifies that
  824.      the line number of the following line of input, in its original
  825.      source file, was LINENUM.
  826.  
  827. `#line LINENUM FILENAME'
  828.      Here LINENUM is a decimal integer constant and FILENAME is a
  829.      string constant.  This specifies that the following line of input
  830.      came originally from source file FILENAME and its line number there
  831.      was LINENUM.  Keep in mind that FILENAME is not just a file name;
  832.      it is surrounded by doublequote characters so that it looks like a
  833.      string constant.
  834.  
  835. `#line ANYTHING ELSE'
  836.      ANYTHING ELSE is checked for macro calls, which are expanded.  The
  837.      result should be a decimal integer constant followed optionally by
  838.      a string constant, as described above.
  839.  
  840.    `#line' commands alter the results of the `__FILE__' and `__LINE__'
  841. predefined macros from that point on.  *Note Standard Predefined::.
  842.  
  843.    The output of the preprocessor (which is the input for the rest of
  844. the compiler) contains commands that look much like `#line' commands.
  845. They start with just `#' instead of `#line', but this is followed by a
  846. line number and file name as in `#line'.  *Note Output::.
  847.  
  848. File: cpp.info,  Node: Other Commands,  Next: Output,  Prev: Combining Sources,  Up: Top
  849.  
  850. Miscellaneous Preprocessor Commands
  851. ===================================
  852.  
  853.    This section describes three additional preprocessor commands.  They
  854. are not very useful, but are mentioned for completeness.
  855.  
  856.    The "null command" consists of a `#' followed by a Newline, with
  857. only whitespace (including comments) in between.  A null command is
  858. understood as a preprocessor command but has no effect on the
  859. preprocessor output.  The primary significance of the existence of the
  860. null command is that an input line consisting of just a `#' will
  861. produce no output, rather than a line of output containing just a `#'.
  862. Supposedly some old C programs contain such lines.
  863.  
  864.    The ANSI standard specifies that the `#pragma' command has an
  865. arbitrary, implementation-defined effect.  In the GNU C preprocessor,
  866. `#pragma' commands are not used, except for `#pragma once' (*note
  867. Once-Only::.).  However, they are left in the preprocessor output, so
  868. they are available to the compilation pass.
  869.  
  870.    The `#ident' command is supported for compatibility with certain
  871. other systems.  It is followed by a line of text.  On some systems, the
  872. text is copied into a special place in the object file; on most systems,
  873. the text is ignored and this command has no effect.  Typically `#ident'
  874. is only used in header files supplied with those systems where it is
  875. meaningful.
  876.  
  877. File: cpp.info,  Node: Output,  Next: Invocation,  Prev: Other Commands,  Up: Top
  878.  
  879. C Preprocessor Output
  880. =====================
  881.  
  882.    The output from the C preprocessor looks much like the input, except
  883. that all preprocessor command lines have been replaced with blank lines
  884. and all comments with spaces.  Whitespace within a line is not altered;
  885. however, a space is inserted after the expansions of most macro calls.
  886.  
  887.    Source file name and line number information is conveyed by lines of
  888. the form
  889.  
  890.      # LINENUM FILENAME FLAGS
  891.  
  892. which are inserted as needed into the middle of the input (but never
  893. within a string or character constant).  Such a line means that the
  894. following line originated in file FILENAME at line LINENUM.
  895.  
  896.    After the file name comes zero or more flags, which are `1', `2' or
  897. `3'.  If there are multiple flags, spaces separate them.  Here is what
  898. the flags mean:
  899.  
  900. `1'
  901.      This indicates the start of a new file.
  902.  
  903. `2'
  904.      This indicates returning to a file (after having included another
  905.      file).
  906.  
  907. `3'
  908.      This indicates that the following text comes from a system header
  909.      file, so certain warnings should be suppressed.
  910.  
  911. File: cpp.info,  Node: Invocation,  Next: Concept Index,  Prev: Output,  Up: Top
  912.  
  913. Invoking the C Preprocessor
  914. ===========================
  915.  
  916.    Most often when you use the C preprocessor you will not have to
  917. invoke it explicitly: the C compiler will do so automatically.
  918. However, the preprocessor is sometimes useful individually.
  919.  
  920.    The C preprocessor expects two file names as arguments, INFILE and
  921. OUTFILE.  The preprocessor reads INFILE together with any other files
  922. it specifies with `#include'.  All the output generated by the combined
  923. input files is written in OUTFILE.
  924.  
  925.    Either INFILE or OUTFILE may be `-', which as INFILE means to read
  926. from standard input and as OUTFILE means to write to standard output.
  927. Also, if OUTFILE or both file names are omitted, the standard output
  928. and standard input are used for the omitted file names.
  929.  
  930.    Here is a table of command options accepted by the C preprocessor.
  931. These options can also be given when compiling a C program; they are
  932. passed along automatically to the preprocessor when it is invoked by the
  933. compiler.
  934.  
  935. `-P'
  936.      Inhibit generation of `#'-lines with line-number information in
  937.      the output from the preprocessor (*note Output::.).  This might be
  938.      useful when running the preprocessor on something that is not C
  939.      code and will be sent to a program which might be confused by the
  940.      `#'-lines.
  941.  
  942. `-C'
  943.      Do not discard comments: pass them through to the output file.
  944.      Comments appearing in arguments of a macro call will be copied to
  945.      the output before the expansion of the macro call.
  946.  
  947. `-traditional'
  948.      Try to imitate the behavior of old-fashioned C, as opposed to ANSI
  949.      C.
  950.  
  951.         * Traditional macro expansion pays no attention to singlequote
  952.           or doublequote characters; macro argument symbols are
  953.           replaced by the argument values even when they appear within
  954.           apparent string or character constants.
  955.  
  956.         * Traditionally, it is permissible for a macro expansion to end
  957.           in the middle of a string or character constant.  The
  958.           constant continues into the text surrounding the macro call.
  959.  
  960.         * However, traditionally the end of the line terminates a
  961.           string or character constant, with no error.
  962.  
  963.         * In traditional C, a comment is equivalent to no text at all.
  964.           (In ANSI C, a comment counts as whitespace.)
  965.  
  966.         * Traditional C does not have the concept of a "preprocessing
  967.           number".  It considers `1.0e+4' to be three tokens: `1.0e',
  968.           `+', and `4'.
  969.  
  970.         * A macro is not suppressed within its own definition, in
  971.           traditional C.  Thus, any macro that is used recursively
  972.           inevitably causes an error.
  973.  
  974.         * The character `#' has no special meaning within a macro
  975.           definition in traditional C.
  976.  
  977.         * In traditional C, the text at the end of a macro expansion
  978.           can run together with the text after the macro call, to
  979.           produce a single token.  (This is impossible in ANSI C.)
  980.  
  981.         * Traditionally, `\' inside a macro argument suppresses the
  982.           syntactic significance of the following character.
  983.  
  984. `-trigraphs'
  985.      Process ANSI standard trigraph sequences.  These are
  986.      three-character sequences, all starting with `??', that are
  987.      defined by ANSI C to stand for single characters.  For example,
  988.      `??/' stands for `\', so `'??/n'' is a character constant for a
  989.      newline.  Strictly speaking, the GNU C preprocessor does not
  990.      support all programs in ANSI Standard C unless `-trigraphs' is
  991.      used, but if you ever notice the difference it will be with relief.
  992.  
  993.      You don't want to know any more about trigraphs.
  994.  
  995. `-pedantic'
  996.      Issue warnings required by the ANSI C standard in certain cases
  997.      such as when text other than a comment follows `#else' or `#endif'.
  998.  
  999. `-pedantic-errors'
  1000.      Like `-pedantic', except that errors are produced rather than
  1001.      warnings.
  1002.  
  1003. `-Wtrigraphs'
  1004.      Warn if any trigraphs are encountered (assuming they are enabled).
  1005.  
  1006. `-Wcomment'
  1007.      Warn whenever a comment-start sequence `/*' appears in a comment.
  1008.  
  1009. `-Wall'
  1010.      Requests both `-Wtrigraphs' and `-Wcomment' (but not
  1011.      `-Wtraditional').
  1012.  
  1013. `-Wtraditional'
  1014.      Warn about certain constructs that behave differently in
  1015.      traditional and ANSI C.
  1016.  
  1017. `-I DIRECTORY'
  1018.      Add the directory DIRECTORY to the end of the list of directories
  1019.      to be searched for header files (*note Include Syntax::.).  This
  1020.      can be used to override a system header file, substituting your
  1021.      own version, since these directories are searched before the system
  1022.      header file directories.  If you use more than one `-I' option,
  1023.      the directories are scanned in left-to-right order; the standard
  1024.      system directories come after.
  1025.  
  1026. `-I-'
  1027.      Any directories specified with `-I' options before the `-I-'
  1028.      option are searched only for the case of `#include "FILE"'; they
  1029.      are not searched for `#include <FILE>'.
  1030.  
  1031.      If additional directories are specified with `-I' options after
  1032.      the `-I-', these directories are searched for all `#include'
  1033.      commands.
  1034.  
  1035.      In addition, the `-I-' option inhibits the use of the current
  1036.      directory as the first search directory for `#include "FILE"'.
  1037.      Therefore, the current directory is searched only if it is
  1038.      requested explicitly with `-I.'.  Specifying both `-I-' and `-I.'
  1039.      allows you to control precisely which directories are searched
  1040.      before the current one and which are searched after.
  1041.  
  1042. `-nostdinc'
  1043.      Do not search the standard system directories for header files.
  1044.      Only the directories you have specified with `-I' options (and the
  1045.      current directory, if appropriate) are searched.
  1046.  
  1047. `-nostdinc++'
  1048.      Do not search for header files in the C++-specific standard
  1049.      directories, but do still search the other standard directories.
  1050.      (This option is used when building libg++.)
  1051.  
  1052. `-D NAME'
  1053.      Predefine NAME as a macro, with definition `1'.
  1054.  
  1055. `-D NAME=DEFINITION'
  1056.      Predefine NAME as a macro, with definition DEFINITION.  There are
  1057.      no restrictions on the contents of DEFINITION, but if you are
  1058.      invoking the preprocessor from a shell or shell-like program you
  1059.      may need to use the shell's quoting syntax to protect characters
  1060.      such as spaces that have a meaning in the shell syntax.  If you
  1061.      use more than one `-D' for the same NAME, the rightmost definition
  1062.      takes effect.
  1063.  
  1064. `-U NAME'
  1065.      Do not predefine NAME.  If both `-U' and `-D' are specified for
  1066.      one name, the `-U' beats the `-D' and the name is not predefined.
  1067.  
  1068. `-undef'
  1069.      Do not predefine any nonstandard macros.
  1070.  
  1071. `-A PREDICATE(ANSWER)'
  1072.      Make an assertion with the predicate PREDICATE and answer ANSWER.
  1073.      *Note Assertions::.
  1074.  
  1075.      You can use `-A-' to disable all predefined assertions; it also
  1076.      undefines all predefined macros that identify the type of target
  1077.      system.
  1078.  
  1079. `-dM'
  1080.      Instead of outputting the result of preprocessing, output a list of
  1081.      `#define' commands for all the macros defined during the execution
  1082.      of the preprocessor, including predefined macros.  This gives you
  1083.      a way of finding out what is predefined in your version of the
  1084.      preprocessor; assuming you have no file `foo.h', the command
  1085.  
  1086.           touch foo.h; cpp -dM foo.h
  1087.  
  1088.      will show the values of any predefined macros.
  1089.  
  1090. `-dD'
  1091.      Like `-dM' except in two respects: it does *not* include the
  1092.      predefined macros, and it outputs *both* the `#define' commands
  1093.      and the result of preprocessing.  Both kinds of output go to the
  1094.      standard output file.
  1095.  
  1096. `-M'
  1097.      Instead of outputting the result of preprocessing, output a rule
  1098.      suitable for `make' describing the dependencies of the main source
  1099.      file.  The preprocessor outputs one `make' rule containing the
  1100.      object file name for that source file, a colon, and the names of
  1101.      all the included files.  If there are many included files then the
  1102.      rule is split into several lines using `\'-newline.
  1103.  
  1104.      This feature is used in automatic updating of makefiles.
  1105.  
  1106. `-MM'
  1107.      Like `-M' but mention only the files included with `#include
  1108.      "FILE"'.  System header files included with `#include <FILE>' are
  1109.      omitted.
  1110.  
  1111. `-MD'
  1112.      Like `-M' but the dependency information is written to files with
  1113.      names made by replacing `.c' with `.d' at the end of the input
  1114.      file names.  This is in addition to compiling the file as
  1115.      specified--`-MD' does not inhibit ordinary compilation the way
  1116.      `-M' does.
  1117.  
  1118.      In Mach, you can use the utility `md' to merge the `.d' files into
  1119.      a single dependency file suitable for using with the `make'
  1120.      command.
  1121.  
  1122. `-MMD'
  1123.      Like `-MD' except mention only user header files, not system
  1124.      header files.
  1125.  
  1126. `-H'
  1127.      Print the name of each header file used, in addition to other
  1128.      normal activities.
  1129.  
  1130. `-imacros FILE'
  1131.      Process FILE as input, discarding the resulting output, before
  1132.      processing the regular input file.  Because the output generated
  1133.      from FILE is discarded, the only effect of `-imacros FILE' is to
  1134.      make the macros defined in FILE available for use in the main
  1135.      input.
  1136.  
  1137. `-include FILE'
  1138.      Process FILE as input, and include all the resulting output,
  1139.      before processing the regular input file.
  1140.  
  1141. `-idirafter DIR'
  1142.      Add the directory DIR to the second include path.  The directories
  1143.      on the second include path are searched when a header file is not
  1144.      found in any of the directories in the main include path (the one
  1145.      that `-I' adds to).
  1146.  
  1147. `-iprefix PREFIX'
  1148.      Specify PREFIX as the prefix for subsequent `-iwithprefix' options.
  1149.  
  1150. `-iwithprefix DIR'
  1151.      Add a directory to the second include path.  The directory's name
  1152.      is made by concatenating PREFIX and DIR, where PREFIX was
  1153.      specified previously with `-iprefix'.
  1154.  
  1155. `-lang-c'
  1156. `-lang-c++'
  1157. `-lang-objc'
  1158. `-lang-objc++'
  1159.      Specify the source language.  `-lang-c++' makes the preprocessor
  1160.      handle C++ comment syntax (comments may begin with `//', in which
  1161.      case they end at end of line), and includes extra default include
  1162.      directories for C++; and `-lang-objc' enables the Objective C
  1163.      `#import' command.  `-lang-c' explicitly turns off both of these
  1164.      extensions, and `-lang-objc++' enables both.
  1165.  
  1166.      These options are generated by the compiler driver `gcc', but not
  1167.      passed from the `gcc' command line.
  1168.  
  1169. `-lint'
  1170.      Look for commands to the program checker `lint' embedded in
  1171.      comments, and emit them preceded by `#pragma lint'.  For example,
  1172.      the comment `/* NOTREACHED */' becomes `#pragma lint NOTREACHED'.
  1173.  
  1174.      This option is available only when you call `cpp' directly; `gcc'
  1175.      will not pass it from its command line.
  1176.  
  1177. `-$'
  1178.      Forbid the use of `$' in identifiers.  This is required for ANSI
  1179.      conformance.  `gcc' automatically supplies this option to the
  1180.      preprocessor if you specify `-ansi', but `gcc' doesn't recognize
  1181.      the `-$' option itself--to use it without the other effects of
  1182.      `-ansi', you must call the preprocessor directly.
  1183.  
  1184. File: cpp.info,  Node: Concept Index,  Next: Index,  Prev: Invocation,  Up: Top
  1185.  
  1186. Concept Index
  1187. *************
  1188.  
  1189. * Menu:
  1190.  
  1191. * assertions:                           Assertions.
  1192. * assertions, undoing:                  Assertions.
  1193. * cascaded macros:                      Cascaded Macros.
  1194. * commands:                             Commands.
  1195. * concatenation:                        Concatenation.
  1196. * conditionals:                         Conditionals.
  1197. * header file:                          Header Files.
  1198. * inheritance:                          Inheritance.
  1199. * line control:                         Combining Sources.
  1200. * macro body uses macro:                Cascaded Macros.
  1201. * null command:                         Other Commands.
  1202. * options:                              Invocation.
  1203. * output format:                        Output.
  1204. * overriding a header file:             Inheritance.
  1205. * predefined macros:                    Predefined.
  1206. * predicates:                           Assertions.
  1207. * preprocessor commands:                Commands.
  1208. * redefining macros:                    Redefining.
  1209. * repeated inclusion:                   Once-Only.
  1210. * retracting assertions:                Assertions.
  1211. * second include path:                  Invocation.
  1212. * self-reference:                       Self-Reference.
  1213. * semicolons (after macro calls):       Swallow Semicolon.
  1214. * side effects (in macro arguments):    Side Effects.
  1215. * stringification:                      Stringification.
  1216. * testing predicates:                   Assertions.
  1217. * unassert:                             Assertions.
  1218. * undefining macros:                    Undefining.
  1219. * unsafe macros:                        Side Effects.
  1220.  
  1221.