cpp.info 75 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936
  1. Info file cpp.info, produced by texinfo-format-buffer -*-Text-*-
  2. from file cpp.texinfo
  3. This file documents the GNU C Preprocessor.
  4. Copyright (C) 1987 Richard M. Stallman.
  5. Permission is granted to make and distribute verbatim copies of
  6. this manual provided the copyright notice and this permission notice
  7. are preserved on all copies.
  8. Permission is granted to copy and distribute modified versions of this
  9. manual under the conditions for verbatim copying, provided also that
  10. the entire resulting derived work is distributed under the terms of a
  11. permission notice identical to this one.
  12. Permission is granted to copy and distribute translations of this manual
  13. into another language, under the above conditions for modified versions.
  14. 
  15. File: cpp.info Node: Top, Up: (DIR), Next: Global Actions
  16. The C Preprocessor
  17. ******************
  18. The C preprocessor is a "macro processor" that is used automatically by
  19. the C compiler to transform your program before actual compilation. It is
  20. called a macro processor because it allows you to define "macros",
  21. which are brief abbreviations for longer constructs.
  22. The C preprocessor provides four separate facilities that you can use as
  23. you see fit:
  24. * Inclusion of header files. These are files of declarations that can be
  25. substituted into your program.
  26. * Macro expansion. You can define "macros", which are abbreviations
  27. for arbitrary fragments of C code, and then the C preprocessor will
  28. replace the macros with their definitions throughout the program.
  29. * Conditional compilation. Using special preprocessor commands, you
  30. can include or exclude parts of the program according to various
  31. conditions.
  32. * Line control. If you use a program to combine or rearrange source files into
  33. an intermediate file which is then compiled, you can use line control
  34. to inform the compiler of where each source line originally came from.
  35. C preprocessors vary in some details. This manual discusses the GNU C
  36. preprocessor, the C Compatible Compiler Preprocessor. The GNU C
  37. preprocessor provides a superset of the features of ANSI Standard C.
  38. ANSI Standard C requires the rejection of many harmless constructs commonly
  39. used by today's C programs. Such incompatibility would be inconvenient for
  40. users, so the GNU C preprocessor is configured to accept these constructs
  41. by default. Strictly speaking, to get ANSI Standard C, you must use the
  42. options `-T', `-undef' and `-pedantic', but in practice the
  43. consequences of having strict ANSI Standard C make it undesirable to do
  44. this. *Note Invocation::.
  45. * Menu:
  46. * Global Actions:: Actions made uniformly on all input files.
  47. * Commands:: General syntax of preprocessor commands.
  48. * Header Files:: How and why to use header files.
  49. * Macros:: How and why to use macros.
  50. * Conditionals:: How and why to use conditionals.
  51. * Combining Sources:: Use of line control when you combine source files.
  52. * Other Commands:: Miscellaneous preprocessor commands.
  53. * Output:: Format of output from the C preprocessor.
  54. * Invocation:: How to invoke the preprocessor; command options.
  55. * Concept Index:: Index of concepts and terms.
  56. * Index:: Index of commands, predefined macros and options.
  57. 
  58. File: cpp.info Node: Global Actions, Prev: Top, Up: Top, Next: Commands
  59. Transformations Made Globally
  60. =============================
  61. Most C preprocessor features are inactive unless you give specific commands
  62. to request their use. (Preprocessor commands are lines starting with
  63. `#'; *Note Commands::). But there are three transformations that the
  64. preprocessor always makes on all the input it receives, even in the absence
  65. of commands.
  66. * All C comments are replaced with single spaces.
  67. * Backslash-Newline sequences are deleted, no matter where. This
  68. feature allows you to break long lines for cosmetic purposes without
  69. changing their meaning.
  70. * Predefined macro names are replaced with their expansions
  71. (*Note Predefined::).
  72. The first two transformations are done *before* nearly all other parsing
  73. and before preprocessor commands are recognized. Thus, for example, you
  74. can split a line cosmetically with Backslash-Newline anywhere (except
  75. when trigraphs are in use; see below).
  76. /*
  77. */ # /*
  78. */ defi\
  79. ne FO\
  80. O 10\
  81. 20
  82. is equivalent into `#define FOO 1020'. You can split even an escape
  83. sequence with Backslash-Newline. For example, you can split `"foo\bar"'
  84. between the `\' and the `b' to get
  85. "foo\\
  86. bar"
  87. This behavior is unclean: in all other contexts, a Backslash can be
  88. inserted in a string constant as an ordinary character by writing a double
  89. Backslash, and this creates an exception. But the ANSI C standard requires
  90. it. (Strict ANSI C does not allow Newlines in string constants, so they
  91. do not consider this a problem.)
  92. But there are a few exceptions to all three transformations.
  93. * C comments and predefined macro names are not recognized inside a
  94. `#include' command in which the file name is delimited with
  95. `<' and `>'.
  96. * C comments and predefined macro names are never recognized within a
  97. character or string constant. (Strictly speaking, this is the rule,
  98. not an exception, but it is worth noting here anyway.)
  99. * Backslash-Newline may not safely be used within an ANSI "trigraph".
  100. Trigraphs are converted before Backslash-Newline is deleted. If you
  101. write what looks like a trigraph with a Backslash-Newline inside, the
  102. Backslash-Newline is deleted as usual, but it is then too late to
  103. recognize the trigraph.
  104. This exception is relevant only if you use the `-T' option to
  105. enable trigraph processing. *Note Invocation::.
  106. 
  107. File: cpp.info Node: Commands, Prev: Global Actions, Up: Top, Next: Header Files
  108. Preprocessor Commands
  109. =====================
  110. Most preprocessor features are active only if you use preprocessor commands
  111. to request their use.
  112. Preprocessor commands are lines in your program that start with `#'.
  113. The `#' is followed by an identifier that is the "command name".
  114. For example, `#define' is the command that defines a macro.
  115. Whitespace is also allowed before and after the `#'.
  116. The set of valid command names is fixed. Programs cannot define new
  117. preprocessor commands.
  118. Some command names require arguments; these make up the rest of the command
  119. line and must be separated from the command name by whitespace. For example,
  120. `#define' must be followed by a macro name and the intended expansion
  121. of the macro.
  122. A preprocessor command cannot be more than one line in normal circumstances.
  123. It may be split cosmetically with Backslash-Newline, but that has no effect
  124. on its meaning. Comments containing Newlines can also divide the command into
  125. multiple lines, but the comments are changed to Spaces before the command
  126. is interpreted. The only way a significant Newline can occur in a preprocessor
  127. command is within a string constant or character constant. Note that
  128. most C compilers that might be applied to the output from the preprocessor
  129. do not accept string or character constants containing Newlines.
  130. The `#' and the command name cannot come from a macro expansion. For
  131. example, if `foo' is defined as a macro expanding to `define',
  132. that does not make `#foo' a valid preprocessor command.
  133. 
  134. File: cpp.info Node: Header Files, Prev: Commands, Up: Top, Next: Macros
  135. Header Files
  136. ============
  137. A header file is a file containing C declarations and macro definitions
  138. (*Note Macros::) to be shared between several source files. You request
  139. the use of a header file in your program with the C preprocessor command
  140. `#include'.
  141. 
  142. File: cpp.info Node: Header Uses, Prev: Header Files, Up: Header Files, Next: Include Syntax
  143. Uses of Header Files
  144. --------------------
  145. Header files serve two kinds of purposes.
  146. * System header files declare the interfaces to parts of the operating
  147. system. You include them in your program to supply the definitions
  148. you need to invoke system calls and libraries.
  149. * Your own header files contain declarations for interfaces between the
  150. source files of your program. Each time you have a group of related
  151. declarations and macro definitions all or most of which are needed in
  152. several different source files, it is a good idea to create a header
  153. file for them.
  154. Including a header file produces the same results in C compilation as
  155. copying the header file into each source file that needs it. But such
  156. copying would be time-consuming and error-prone. With a header file, the
  157. related declarations appear in only one place. If they need to be changed,
  158. they can be changed in one place, and programs that include the header file
  159. will automatically use the new version when next recompiled. The header
  160. file eliminates the labor of finding and changing all the copies as well as
  161. the risk that a failure to find one copy will result in inconsistencies
  162. within a program.
  163. The usual convention is to give header files names that end with `.h'.
  164. 
  165. File: cpp.info Node: Include Syntax, Prev: Header Uses, Up: Header Files, Next: Include Operation
  166. The `#include' Command
  167. ----------------------
  168. Both user and system header files are included using the preprocessor
  169. command `#include'. It has three variants:
  170. `#include <FILE>'
  171. This variant is used for system header files. It searches for a file
  172. named FILE in a list of directories specified by you, then in a
  173. standard list of system directories. You specify directories to
  174. search for header files with the command option `-I'
  175. (*Note Invocation::).
  176. The parsing of this form of `#include' is slightly special because
  177. comments are not recognized within the `<...>'. Thus, in `#include
  178. <x/*y>' the `/*' does not start a comment and the command specifies
  179. inclusion of a system header file named `x/*y'. Of course, a header
  180. file with such a name is unlikely to exist on Unix, where shell
  181. wildcard features would make it hard to manipulate.
  182. The argument FILE may not contain a `>' character. It may,
  183. however, contain a `<' character.
  184. `#include "FILE"'
  185. This variant is used for header files of your own program. It
  186. searches for a file named FILE first in the current working
  187. directory, then in the same directories used for system header
  188. files. The current working directory is tried first because it is
  189. presumed to be the location of the files of the program being
  190. compiled.
  191. The argument FILE may not contain `"' characters. If
  192. backslashes occur within FILE, they are considered ordinary text
  193. characters, not escape characters. None of the character escape
  194. sequences appropriate to string constants in C are processed. Thus,
  195. `#include "x\n\\y"' specifies a filename containing three
  196. backslashes. It is not clear why this behavior is ever useful, but
  197. the ANSI standard specifies it.
  198. `#include ANYTHING ELSE'
  199. This variant is called a "computed #include". Any `#include'
  200. command whose argument does not fit the above two forms is a computed
  201. include. The text ANYTHING ELSE is checked for macro calls,
  202. which are expanded (*Note Macros::). When this is done, the result
  203. must fit one of the above two variants.
  204. This feature allows you to define a macro which controls the file name
  205. to be used at a later point in the program. One application of this
  206. is to allow a site-configuration file for your program to specify the
  207. names of the system include files to be used. This can help in
  208. porting the program to various operating systems in which the
  209. necessary system header files are found in different places.
  210. 
  211. File: cpp.info Node: Include Operation, Prev: Include Syntax, Up: Header Files
  212. How `#include' Works
  213. --------------------
  214. The `#include' command works by directing the C preprocessor to scan
  215. the specified file as input before continuing with the rest of the current
  216. file. The output from the preprocessor contains the output already
  217. generated, followed by the output resulting from the included file,
  218. followed by the output that comes from the text after the `#include'
  219. command. For example, given two files as follows:
  220. /* File program.c */
  221. int x;
  222. #include "header.h"
  223. main ()
  224. {
  225. printf (test ());
  226. }
  227. /* File header.h */
  228. char *test ();
  229. the output generated by the C preprocessor for `program.c' as input
  230. would be
  231. int x;
  232. char *test ();
  233. main ()
  234. {
  235. printf (test ());
  236. }
  237. Included files are not limited to declarations and macro definitions; they
  238. are merely the typical use. Any fragment of a C program can be included
  239. from another file. The include file could even contain the beginning of a
  240. statement that is concluded in the containing file, or the end of a
  241. statement that was started in the including file. However, a comment or a
  242. string or character constant may not start in the included file and finish
  243. in the including file. An unterminated comment, string constant or
  244. character constant in an included file is considered to end (with an error
  245. message) at the end of the file.
  246. The line following the `#include' command is always treated as a
  247. separate line by the C preprocessor even if the included file lacks a final
  248. newline.
  249. 
  250. File: cpp.info Node: Macros, Prev: Header Files, Up: Top, Next: Conditionals
  251. Macros
  252. ======
  253. A macro is a sort of abbreviation which you can define once and then
  254. use later. There are many complicated features associated with macros
  255. in the C preprocessor.
  256. * Menu:
  257. * Simple Macros:: Macros that always expand the same way.
  258. * Argument Macros:: Macros that accept arguments that are substituted
  259. into the macro expansion.
  260. * Predefined:: Predefined macros that are always available.
  261. * Stringification:: Macro arguments converted into string constants.
  262. * Concatenation:: Building tokens from parts taken from macro arguments.
  263. * Undefining:: Cancelling a macro's definition.
  264. * Redefining:: Changing a macro's definition.
  265. * Macro Pitfalls:: Macros can confuse the unwary. Here we explain
  266. several common problems and strange features.
  267. 
  268. File: cpp.info Node: Simple Macros, Prev: Macros, Up: Macros, Next: Argument Macros
  269. Simple Macros
  270. -------------
  271. A "simple macro" is a kind of abbreviation. It is a name which stands
  272. for a fragment of code.
  273. Before you can use a macro, you must "define" it explicitly with the
  274. `#define' command. `#define' is followed by the name of the
  275. macro and then the code it should be an abbreviation for. For example,
  276. #define BUFFER_SIZE 1020
  277. defines a macro named `BUFFER_SIZE' as an abbreviation for the text
  278. `1020'. Therefore, if somewhere after this `#define' command
  279. there comes a C statement of the form
  280. foo = (char *) xmalloc (BUFFER_SIZE);
  281. then the C preprocessor will recognize and "expand" the macro
  282. `BUFFER_SIZE', resulting in
  283. foo = (char *) xmalloc (1020);
  284. the definition must be a single line; however, it may not end in the
  285. middle of a multi-line string constant or character constant.
  286. The use of all upper case for macro names is a standard convention.
  287. Programs are easier to read when it is possible to tell at a glance which
  288. names are macros.
  289. Normally, a macro definition must be a single line, like all C preprocessor
  290. commands. (You can split a long macro definition cosmetically with
  291. Backslash-Newline.) There is one exception: Newlines can be included in
  292. the macro definition if within a string or character constant. By the same
  293. token, it is not possible for a macro definition to contain an unbalanced
  294. quote character; the definition automatically extends to include the
  295. matching quote character that ends the string or character constant.
  296. Comments within a macro definition may contain Newlines, which make no
  297. difference since the comments are entirely replaced with Spaces regardless
  298. of their contents.
  299. Aside from the above, there is no restriction on what can go in a macro
  300. body. Parentheses need not balance. The body need not resemble valid C
  301. code. (Of course, you might get error messages from the C compiler when
  302. you use the macro.)
  303. The C preprocessor scans your program sequentially, so macro definitions
  304. take effect at the place you write them. Therefore, the following input to
  305. the C preprocessor
  306. foo = X;
  307. #define X 4
  308. bar = X;
  309. produces as output
  310. foo = X;
  311. bar = 4;
  312. After the preprocessor expands a macro name, the macro's definition body is
  313. appended to the front of the remaining input, and the check for macro calls
  314. continues. Therefore, the macro body can contain calls to other macros.
  315. For example, after
  316. #define BUFSIZE 1020
  317. #define TABLESIZE BUFSIZE
  318. the name `TABLESIZE' when used in the program would go through two
  319. stages of expansion, resulting ultimately in `1020'.
  320. This is not at all the same as defining `TABLESIZE' to be `1020'.
  321. The `#define' for `TABLESIZE' uses exactly the body you
  322. specify---in this case, `BUFSIZE'---and does not check to see whether
  323. it too is the name of a macro. It's only when you *use* `TABLESIZE'
  324. that the result of its expansion is checked for more macro names.
  325. *Note Cascaded Macros::.
  326. 
  327. File: cpp.info Node: Argument Macros, Prev: Simple Macros, Up: Macros, Next: Predefined
  328. Macros with Arguments
  329. ---------------------
  330. A simple macro always stands for exactly the same text, each time it is
  331. used. Macros can be more flexible when they accept "arguments".
  332. Arguments are fragments of code that you supply each time the macro is
  333. used. These fragments are included in the expansion of the macro according
  334. to the directions in the macro definition.
  335. To define a macro that uses arguments, you write a `#define' command
  336. with a list of "argument names" in parentheses after the name of the
  337. macro. The argument names may be any valid C identifiers, separated by
  338. commas and optionally whitespace. The open-parenthesis must follow the
  339. macro name immediately, with no space in between.
  340. For example, here is a macro that computes the minimum of two numeric
  341. values, as it is defined in many C programs:
  342. #define min(X, Y) ((X) < (Y) ? (X) : (Y))
  343. (This is not the best way to define a "minimum" macro in GNU C.
  344. *Note Side Effects::, for more information.)
  345. To use a macro that expects arguments, you write the name of the macro
  346. followed by a list of "actual arguments" in parentheses. separated by
  347. commas. The number of actual arguments you give must match the number of
  348. arguments the macro expects. Examples of use of the macro `min'
  349. include `min (1, 2)' and `min (x + 28, *p)'.
  350. The expansion text of the macro depends on the arguments you use.
  351. Each of the argument names of the macro is replaced, throughout the
  352. macro definition, with the corresponding actual argument. Using the
  353. same macro `min' defined above, `min (1, 2)' expands into
  354. ((1) < (2) ? (1) : (2))
  355. where `1' has been substituted for `X' and `2' for `Y'.
  356. Likewise, `min (x + 28, *p)' expands into
  357. ((x + 28) < (*p) ? (x + 28) : (*p))
  358. Parentheses in the actual arguments must balance; a comma within
  359. parentheses does not end an argument. However, there is no requirement for
  360. brackets or braces to balance; thus, if you want to supply `array[x =
  361. y, x + 1]' as an argument, you must write it as `array[(x = y, x +
  362. 1)]', which is equivalent C code.
  363. After the actual arguments are substituted into the macro body, the entire
  364. result is appended to the front of the remaining input, and the check for
  365. macro calls continues. Therefore, the actual arguments can contain calls
  366. to other macros, either with or without arguments, or even to the same
  367. macro. The macro body can also contain calls to other macros. For
  368. example, `min (min (a, b), c)' expands into
  369. ((((a) < (b) ? (a) : (b))) < (c)
  370. ? (((a) < (b) ? (a) : (b)))
  371. : (c))
  372. (Line breaks shown here for clarity would not actually be generated.)
  373. If you use the macro name followed by something other than an
  374. open-parenthesis (after ignoring any spaces, tabs and comments that
  375. follow), it is not a call to the macro, and the preprocessor does not
  376. change what you have written. Therefore, it is possible for the same name
  377. to be a variable or function in your program as well as a macro, and you
  378. can choose in each instance whether to refer to the macro (if an actual
  379. argument list follows) or the variable or function (if an argument list
  380. does not follow).
  381. Such dual use of one name could be confusing and should be avoided
  382. except when the two meanings are effectively synonymous: that is, when the
  383. name is both a macro and a function and the two have similar effects. You
  384. can think of the name simply as a function; use of the name for purposes
  385. other than calling it (such as, to take the address) will refer to the
  386. function, while calls will expand the macro and generate better but
  387. equivalent code. For example, you can use a function named `min' in
  388. the same source file that defines the macro. If you write `&min' with
  389. no argument list, you refer to the function. If you write `min (x,
  390. bb)', with an argument list, the macro is expanded. If you write
  391. `(min) (a, bb)', where the name `min' is not followed by an
  392. open-parenthesis, the macro is not expanded, so you wind up with a call to
  393. the function `min'.
  394. It is not allowed to define the same name as both a simple macro and
  395. a macro with arguments.
  396. In the definition of a macro with arguments, the list of argument names
  397. must follow the macro name immediately with no space in between. If there
  398. is a space after the macro name, the macro is defined as taking no
  399. arguments, and all the rest of the name is taken to be the expansion. The
  400. reason for this is that it is often useful to define a macro that takes no
  401. arguments and whose definition begins with an identifier in parentheses.
  402. This rule about spaces makes it possible for you to do either this:
  403. #define FOO(x) - 1 / (x)
  404. (which defines `FOO' to take an argument and expand into minus the
  405. reciprocal of that argument) or this:
  406. #define BAR (x) - 1 / (x)
  407. (which defines `BAR' to take no argument and always expand into
  408. `(x) - 1 / (x)').
  409. Note that the *uses* of a macro with arguments can have spaces before
  410. the left parenthesis; it's the *definition* where it matters whether
  411. there is a space.
  412. 
  413. File: cpp.info Node: Predefined, Prev: Argument Macros, Up: Macros, Next: Stringification
  414. Predefined Macros
  415. -----------------
  416. Several simple macros are predefined. You can use them without giving
  417. definitions for them. They fall into two classes: standard macros and
  418. system-specific macros.
  419. * Menu:
  420. * Standard Predefined:: Standard predefined macros.
  421. * Nonstandard Predefined:: Nonstandard predefined macros.
  422. 
  423. File: cpp.info Node: Standard Predefined, Prev: Predefined, Up: Predefined, Next: Nonstandard Predefined
  424. Standard Predefined Macros
  425. ..........................
  426. The standard predefined macros are available with the same meanings
  427. regardless of the machine or operating system on which you are using GNU C.
  428. Their names all start and end with double underscores. Those preceding
  429. `__GNUC__' in this table are standardized by ANSI C; the rest are
  430. GNU C extensions.
  431. `__FILE__'
  432. This macro expands to the name of the current input file, in the form
  433. of a C string constant.
  434. `__LINE__'
  435. This macro expands to the current input line number, in the form of a
  436. decimal integer constant. While we call it a predefined macro, it's
  437. a pretty strange macro, since its "definition" changes with each
  438. new line of source code.
  439. This and `__FILE__' are useful in generating an error message to
  440. report an inconsistency detected by the program; the message can state
  441. the source line at which the inconsistency was detected. For example,
  442. fprintf (stderr, "Internal error: negative string length "
  443. "%d at %s, line %d.",
  444. length, __FILE__, __LINE__);
  445. A `#include' command changes the expansions of `__FILE__'
  446. and `__LINE__' to correspond to the included file. At the end of
  447. that file, when processing resumes on the input file that contained
  448. the `#include' command, the expansions of `__FILE__' and
  449. `__LINE__' revert to the values they had before the
  450. `#include' (but `__LINE__' is then incremented by one as
  451. processing moves to the line after the `#include').
  452. The expansions of both `__FILE__' and `__LINE__' are altered
  453. if a `#line' command is used. *Note Combining Sources::.
  454. `__DATE__'
  455. This macro expands to a string constant that describes the date on
  456. which the preprocessor is being run. The string constant contains
  457. eleven characters and looks like `"Jan 29 1987"' or `"Apr
  458. 1 1905"'.
  459. `__TIME__'
  460. This macro expands to a string constant that describes the time at
  461. which the preprocessor is being run. The string constant contains
  462. eight characters and looks like `"23:59:01"'.
  463. `__STDC__'
  464. This macro expands to the constant 1, to signify that this is ANSI
  465. Standard C. (Whether that is actually true depends on what C compiler
  466. will operate on the output from the preprocessor.)
  467. `__GNUC__'
  468. This macro is defined if and only if this is GNU C. This macro is
  469. defined only when the entire GNU C compiler is in use; if you invoke
  470. the preprocessor directly, `__GNUC__' is undefined.
  471. `__STRICT_ANSI__'
  472. This macro is defined if and only if the `-ansi' switch was
  473. specified when GNU C was invoked. Its definition is the null string.
  474. This macro exists primarily to direct certain GNU header files not to
  475. define certain traditional Unix constructs which are incompatible with
  476. ANSI C.
  477. `__VERSION__'
  478. This macro expands to a string which describes the version number of
  479. GNU C. The string is normally a sequence of decimal numbers separated
  480. by periods, such as `"1.18"'. The only reasonable use of this
  481. macro is to incorporate it into a string constant.
  482. `__OPTIMIZE__'
  483. This macro is defined in optimizing compilations. It causes certain
  484. GNU header files to define alternative macro definitions for some
  485. system library functions. It is unwise to refer to or test the
  486. definition of this macro unless you make very sure that programs will
  487. execute with the same effect regardless.
  488. `__CHAR_UNSIGNED__'
  489. This macro is defined if and only if the data type `char' is
  490. unsigned on the target machine. It exists to cause the standard
  491. header file `limit.h' to work correctly. It is bad practice
  492. to refer to this macro yourself; instead, refer to the standard
  493. macros defined in `limit.h'.
  494. 
  495. File: cpp.info Node: Nonstandard Predefined, Prev: Standard Predefined, Up: Predefined
  496. Nonstandard Predefined Macros
  497. .............................
  498. The C preprocessor normally has several predefined macros that vary between
  499. machines because their purpose is to indicate what type of system and
  500. machine is in use. This manual, being for all systems and machines, cannot
  501. tell you exactly what their names are; instead, we offer a list of some
  502. typical ones.
  503. Some nonstandard predefined macros describe the operating system in use,
  504. with more or less specificity. For example,
  505. `unix'
  506. `unix' is normally predefined on all Unix systems.
  507. `BSD'
  508. `BSD' is predefined on recent versions of Berkeley Unix
  509. (perhaps only in version 4.3).
  510. Other nonstandard predefined macros describe the kind of CPU, with more or
  511. less specificity. For example,
  512. `vax'
  513. `vax' is predefined on Vax computers.
  514. `mc68000'
  515. `mc68000' is predefined on most computers whose CPU is a Motorola
  516. 68000, 68010 or 68020.
  517. `m68k'
  518. `m68k' is also predefined on most computers whose CPU is a 68000,
  519. 68010 or 68020; however, some makers use `mc68000' and some use
  520. `m68k'. Some predefine both names. What happens in GNU C
  521. depends on the system you are using it on.
  522. `M68020'
  523. `M68020' has been observed to be predefined on some systems that
  524. use 68020 CPUs---in addition to `mc68000' and `m68k' that
  525. are less specific.
  526. `ns32000'
  527. `ns32000' is predefined on computers which use the National
  528. Semiconductor 32000 series CPU.
  529. Yet other nonstandard predefined macros describe the manufacturer of
  530. the system. For example,
  531. `sun'
  532. `sun' is predefined on all models of Sun computers.
  533. `pyr'
  534. `pyr' is predefined on all models of Pyramid computers.
  535. `sequent'
  536. `sequent' is predefined on all models of Sequent computers.
  537. These predefined symbols are not only nonstandard, they are contrary to the
  538. ANSI standard because their names do not start with underscores. However,
  539. the GNU C preprocessor would be useless if it did not predefine the same
  540. names that are normally predefined on the system and machine you are using.
  541. Even system header files check the predefined names and will generate
  542. incorrect declarations if they do not find the names that are expected.
  543. The set of nonstandard predefined names in the GNU C preprocessor is
  544. controlled by the macro `CPP_PREDEFINES', which should be a string
  545. containing `-D' options, separated by spaces. For example, on the Sun,
  546. the definition
  547. #define CPP_PREDEFINES "-Dmc68000 -Dsun -Dunix -Dm68k"
  548. is used.
  549. The `-ansi' option which requests complete support for ANSI C
  550. inhibits the definition of these predefined symbols.
  551. 
  552. File: cpp.info Node: Stringification, Prev: Predefined, Up: Macros, Next: Concatenation
  553. Stringification
  554. ---------------
  555. "Stringification" means turning a code fragment into a string constant
  556. whose contents are the text for the code fragment. For example,
  557. stringifying `foo (z)' results in `"foo (z)"'.
  558. In the C preprocessor, stringification is an option available when macro
  559. arguments are substituted into the macro definition. In the body of the
  560. definition, when an argument name appears, the character `#' before
  561. the name specifies stringification of the corresponding actual argument
  562. when it is substituted at that point in the definition. The same argument
  563. may be substituted in other places in the definition without
  564. stringification if the argument name appears in those places with no
  565. `#'.
  566. Here is an example of a macro definition that uses stringification:
  567. #define WARN_IF(EXP) \
  568. do { if (EXP) fprintf (stderr, "Warning: " #EXP "\n"); } while (0)
  569. Here the actual argument for `EXP' is substituted once as given,
  570. into the `if' statement, and once as stringified, into the
  571. argument to `fprintf'. The `do' and `while (0)' are
  572. a kludge to make it possible to write `WARN_IF (ARG);',
  573. which the resemblance of `WARN_IF' to a function would make
  574. C programmers want to do; *Note Swallow Semicolon::).
  575. The stringification feature is limited to transforming one macro argument
  576. into one string constant: there is no way to combine the argument with
  577. other text and then stringify it all together. But the example above shows
  578. how an equivalent result can be obtained in ANSI Standard C using the
  579. feature that adjacent string constants are concatenated as one string
  580. constant. The preprocessor stringifies `EXP''s actual argument
  581. into a separate string constant, resulting in text like
  582. do { if (x == 0) fprintf (stderr, "Warning: " "x == 0" "\n"); } while (0)
  583. but the C compiler then sees three consecutive string constants and
  584. concatenates them into one, producing effectively
  585. do { if (x == 0) fprintf (stderr, "Warning: x == 0\n"); } while (0)
  586. Stringification in C involves more than putting doublequote characters
  587. around the fragment; it is necessary to put backslashes in front of all
  588. doublequote characters, and all backslashes in string and character
  589. constants, in order to get a valid C string constant with the proper
  590. contents. Thus, stringifying `p = "foo\n";' results in `"p =
  591. \"foo\\n\";"'. However, backslashes that are not inside of string or
  592. character constants are not duplicated: `\n' by itself stringifies to
  593. `"\n"'.
  594. Whitespace (including comments) in the text being stringified is handled
  595. according to precise rules. All leading and trailing whitespace is ignored.
  596. Any sequence of whitespace in the middle of the text is converted to
  597. a single space in the stringified result.
  598. 
  599. File: cpp.info Node: Concatenation, Prev: Stringification, Up: Macros, Next: Undefining
  600. Concatenation
  601. -------------
  602. "Concatenation" means joining two strings into one. In the context
  603. of macro expansion, concatenation refers to joining two lexical units
  604. into one longer one. Specifically, an actual argument to the macro can be
  605. concatenated with another actual argument or with fixed text to produce
  606. a longer name. The longer name might be the name of a function,
  607. variable or type, or a C keyword; it might even be the name of another
  608. macro, in which case it will be expanded.
  609. When you define a macro, you request concatenation with the special
  610. operator `##' in the macro body. When the macro is called,
  611. after actual arguments are substituted, all `##' operators are
  612. deleted, and so is any whitespace next to them (including whitespace
  613. that was part of an actual argument). The result is to concatenate
  614. the syntactic tokens on either side of the `##'.
  615. Consider a C program that interprets named commands. There probably needs
  616. to be a table of commands, perhaps an array of structures declared as
  617. follows:
  618. struct command
  619. {
  620. char *name;
  621. void (*function) ();
  622. };
  623. struct command commands[] =
  624. {
  625. { "quit", quit_command},
  626. { "help", help_command},
  627. ...
  628. };
  629. It would be cleaner not to have to give each command name twice, once in
  630. the string constant and once in the function name. A macro which takes the
  631. name of a command as an argument can make this unnecessary. The string
  632. constant can be created with stringification, and the function name by
  633. concatenating the argument with `_command'. Here is how it is done:
  634. #define COMMAND(NAME) { #NAME, NAME ## _command }
  635. struct command commands[] =
  636. {
  637. COMMAND (quit),
  638. COMMAND (help),
  639. ...
  640. };
  641. The usual case of concatenation is concatenating two names (or a name and a
  642. number) into a longer name. But this isn't the only valid case. It is
  643. also possible to concatenate two numbers (or a number and a name, such as
  644. `1.5' and `e3') into a number. Also, multi-character operators
  645. such as `+=' can be formed by concatenation. In some cases it is even
  646. possible to piece together a string constant. However, two pieces of text
  647. that don't together form a valid lexical unit cannot be concatenated. For
  648. example, concatenation with `x' on one side and `+' on the other
  649. is not meaningful because those two characters can't fit together in any
  650. lexical unit of C. The ANSI standard says that such attempts at
  651. concatenation are undefined, but in the GNU C preprocessor it is well
  652. defined: it puts the `x' and `+' side by side with no particular
  653. special results.
  654. Keep in mind that the C preprocessor converts comments to whitespace before
  655. macros are even considered. Therefore, you cannot create a comment by
  656. concatenating `/' and `*': the `/*' sequence that starts a
  657. comment is not a lexical unit, but rather the beginning of a "long" space
  658. character. Also, you can freely use comments next to a `##' in a
  659. macro definition, or in actual arguments that will be concatenated, because
  660. the comments will be converted to spaces at first sight, and concatenation
  661. will later discard the spaces.
  662. 
  663. File: cpp.info Node: Undefining, Prev: Concatenation, Up: Macros, Next: Redefining
  664. Undefining Macros
  665. -----------------
  666. To "undefine" a macro means to cancel its definition. This is done
  667. with the `#undef' command. `#undef' is followed by the macro
  668. name to be undefined.
  669. Like definition, undefinition occurs at a specific point in the source
  670. file, and it applies starting from that point. The name ceases to be a
  671. macro name, and from that point on it is treated by the preprocessor as if
  672. it had never been a macro name.
  673. For example,
  674. #define FOO 4
  675. x = FOO;
  676. #undef FOO
  677. x = FOO;
  678. expands into
  679. x = 4;
  680. x = FOO;
  681. In this example, `FOO' had better be a variable or function as well
  682. as (temporarily) a macro, in order for the result of the expansion to be
  683. valid C code.
  684. The same form of `#undef' command will cancel definitions with
  685. arguments or definitions that don't expect arguments. The `#undef'
  686. command has no effect when used on a name not currently defined as a macro.
  687. 
  688. File: cpp.info Node: Redefining, Prev: Undefining, Up: Macros, Next: Macro Pitfalls
  689. Redefining Macros
  690. -----------------
  691. "Redefining" a macro means defining (with `#define') a name that
  692. is already defined as a macro.
  693. A redefinition is trivial if the new definition is transparently identical
  694. to the old one. You probably wouldn't deliberately write a trivial
  695. redefinition, but they can happen automatically when a header file is
  696. included more than once (*Note Header Files::), so they are accepted
  697. silently and without effect.
  698. Nontrivial redefinition is considered likely to be an error, so
  699. it provokes a warning message from the preprocessor. However, sometimes it
  700. is useful to change the definition of a macro in mid-compilation. You can
  701. inhibit the warning by undefining the macro with `#undef' before the
  702. second definition.
  703. In order for a reefinition to be trivial, the new definition must exactly match
  704. the one already in effect, with two possible exceptions:
  705. * Whitespace may be added or deleted at the beginning or the end.
  706. * Whitespace may be changed in the middle (but not inside strings).
  707. However, it may not be eliminated entirely, and it may not be added
  708. where there was no whitespace at all.
  709. Recall that a comment counts as whitespace.
  710. 
  711. File: cpp.info Node: Macro Pitfalls, Prev: Redefining, Up: Macros
  712. Pitfalls and Subtleties of Macros
  713. ---------------------------------
  714. In this section we describe some special rules that apply to macros and
  715. macro expansion, and point out certain cases in which the rules have
  716. counterintuitive consequences that you must watch out for.
  717. * Menu:
  718. * Misnesting:: Macros can contain unmatched parentheses.
  719. * Macro Parentheses:: Why apparently superfluous parentheses
  720. may be necessary to avoid incorrect grouping.
  721. * Swallow Semicolon:: Macros that look like functions
  722. but expand into compound statements.
  723. * Side Effects:: Unsafe macros that cause trouble when
  724. arguments contain side effects.
  725. * Self-Reference:: Macros whose definitions use the macros' own names.
  726. * Argument Prescan:: Actual arguments are checked for macro calls
  727. before they are substituted.
  728. * Cascaded Macros:: Macros whose definitions use other macros.
  729. 
  730. File: cpp.info Node: Misnesting, Prev: Macro Pitfalls, Up: Macro Pitfalls, Next: Macro Parentheses
  731. Improperly Nested Constructs
  732. ............................
  733. Recall that when a macro is called with arguments, the arguments are
  734. substituted into the macro body and the result is checked, together with
  735. the rest of the input file, for more macro calls.
  736. It is possible to piece together a macro call coming partially from the
  737. macro body and partially from the actual arguments. For example,
  738. #define double(x) (2*(x))
  739. #define call_with_1(x) x(1)
  740. would expand `call_with_1 (double)' into `(2*(1))'.
  741. Macro definitions do not have to have balanced parentheses. By writing an
  742. unbalanced open parenthesis in a macro body, it is possible to create a
  743. macro call that begins inside the macro body but ends outside of it. For
  744. example,
  745. #define strange(file) fprintf (file, "%s %d",
  746. ...
  747. strange(stderr) p, 35)
  748. This bizarre example expands to `fprintf (stderr, "%s %d", p, 35)'!
  749. 
  750. File: cpp.info Node: Macro Parentheses, Prev: Misnesting, Up: Macro Pitfalls, Next: Swallow Semicolon
  751. Unintended Grouping of Arithmetic
  752. .................................
  753. You may have noticed that in most of the macro definition examples shown
  754. above, each occurrence of a macro argument name had parentheses around it.
  755. In addition, another pair of parentheses usually surround the entire macro
  756. definition. Here is why it is best to write macros that way.
  757. Suppose you define a macro as follows
  758. #define ceil_div(x, y) (x + y - 1) / y
  759. whose purpose is to divide, rounding up. (One use for this
  760. operation is to compute how many `int''s are needed to hold
  761. a certain number of `char''s.) Then suppose it is used as follows:
  762. a = ceil_div (b & c, sizeof (int));
  763. This expands into
  764. a = (b & c + sizeof (int) - 1) / sizeof (int);
  765. which does not do what is intended. The operator-precedence rules of
  766. C make it equivalent to this:
  767. a = (b & (c + sizeof (int) - 1)) / sizeof (int);
  768. But what we want is this:
  769. a = ((b & c) + sizeof (int) - 1)) / sizeof (int);
  770. Defining the macro as
  771. #define ceil_div(x, y) ((x) + (y) - 1) / (y)
  772. provides the desired result.
  773. However, unintended grouping can result in another way. Consider
  774. `sizeof ceil_div(1, 2)'. That has the appearance of a C expression
  775. that would compute the size of the type of `ceil_div (1, 2)', but in
  776. fact it means something very different. Here is what it expands to:
  777. sizeof ((1) + (2) - 1) / (2)
  778. This would take the size of an integer and divide it by two. The precedence
  779. rules have put the division outside the `sizeof' when it was intended
  780. to be inside.
  781. Parentheses around the entire macro definition can prevent such problems.
  782. Here, then, is the recommended way to define `ceil_div':
  783. #define ceil_div(x, y) (((x) + (y) - 1) / (y))
  784. 
  785. File: cpp.info Node: Swallow Semicolon, Prev: Macro Parentheses, Up: Macro Pitfalls, Next: Side Effects
  786. Swallowing the Semicolon
  787. ........................
  788. Often it is desirable to define a macro that expands into a compound
  789. statement. Consider, for example, the following macro, that advances a
  790. pointer (the argument `p' says where to find it) across whitespace
  791. characters:
  792. #define SKIP_SPACES (p, limit) \
  793. { register char *lim = (limit); \
  794. while (p != lim) { \
  795. if (*p++ != ' ') { \
  796. p--; break; }}}
  797. Here Backslash-Newline is used to split the macro definition, which must
  798. be a single line, so that it resembles the way such C code would be
  799. layed out if not part of a macro definition.
  800. A call to this macro might be `SKIP_SPACES (p, lim)'. Strictly
  801. speaking, the call expands to a compound statement, which is a complete
  802. statement with no need for a semicolon to end it. But it looks like a
  803. function call. So it minimizes confusion if you can use it like a function
  804. call, writing a semicolon afterward, as in `SKIP_SPACES (p, lim);'
  805. But this can cause trouble before `else' statements, because the
  806. semicolon is actually a null statement. Suppose you write
  807. if (*p != 0)
  808. SKIP_SPACES (p, lim);
  809. else ...
  810. The presence of two statements---the compound statement and a null
  811. statement---in between the `if' condition and the `else'
  812. makes invalid C code.
  813. The definition of the macro `SKIP_SPACES' can be altered to solve
  814. this problem, using a `do ... while' statement. Here is how:
  815. #define SKIP_SPACES (p, limit) \
  816. do { register char *lim = (limit); \
  817. while (p != lim) { \
  818. if (*p++ != ' ') { \
  819. p--; break; }}} \
  820. while (0)
  821. Now `SKIP_SPACES (p, lim);' expands into
  822. do {...} while (0);
  823. which is one statement.
  824. 
  825. File: cpp.info Node: Side Effects, Prev: Swallow Semicolon, Up: Macro Pitfalls, Next: Self-Reference
  826. Duplication of Side Effects
  827. ...........................
  828. Many C programs define a macro `min', for "minimum", like this:
  829. #define min(X, Y) ((X) < (Y) ? (X) : (Y))
  830. When you use this macro with an argument containing a side effect,
  831. as shown here,
  832. next = min (x + y, foo (z));
  833. it expands as follows:
  834. next = ((x + y) < (foo (z)) ? (x + y) : (foo (z)));
  835. where `x + y' has been substituted for `X' and `foo (z)'
  836. for `Y'.
  837. The function `foo' is used only once in the statement as it appears
  838. in the program, but the expression `foo (z)' has been substituted
  839. twice into the macro expansion. As a result, `foo' might be called
  840. two times when the statement is executed. If it has side effects or
  841. if it takes a long time to compute, the results might not be what you
  842. intended. We say that `min' is an "unsafe" macro.
  843. The best solution to this problem is to define `min' in a way that
  844. computes the value of `foo (z)' only once. The C language offers no
  845. way standard way to do this, but it can be done with GNU C extensions as
  846. follows:
  847. #define min(X, Y) \
  848. ({ typeof (X) __x = (X), __y = (Y); \
  849. (__x < __y) ? __x : __y; })
  850. If you do not wish to use GNU C extensions, the only solution is to be
  851. careful when *using* the macro `min'. For example, you can
  852. calculate the value of `foo (z)', save it in a variable, and use that
  853. variable in `min':
  854. #define min(X, Y) ((X) < (Y) ? (X) : (Y))
  855. ...
  856. {
  857. int tem = foo (z);
  858. next = min (x + y, tem);
  859. }
  860. (where I assume that `foo' returns type `int').
  861. 
  862. File: cpp.info Node: Self-Reference, Prev: Side Effects, Up: Macro Pitfalls, Next: Argument Prescan
  863. Self-Referential Macros
  864. .......................
  865. A "self-referential" macro is one whose name appears in its definition.
  866. A special feature of ANSI Standard C is that the self-reference is not
  867. considered a macro call. It is passed into the preprocessor output
  868. unchanged.
  869. Let's consider an example:
  870. #define foo (4 + foo)
  871. where `foo' is also a variable in your program.
  872. Following the ordinary rules, each reference to `foo' will expand into
  873. `(4 + foo)'; then this will be rescanned and will expand into `(4
  874. + (4 + foo))'; and so on until it causes a fatal error (memory full) in the
  875. preprocessor.
  876. However, the special rule about self-reference cuts this process short
  877. after one step, at `(4 + foo)'. Therefore, this macro definition
  878. has the possibly useful effect of causing the program to add 4 to
  879. the value of `foo' wherever `foo' is referred to.
  880. In most cases, it is a bad idea to take advantage of this feature.
  881. A person reading the program who sees that `foo' is a variable will
  882. not expect that it is a macro as well. The reader will come across a
  883. the identifier `foo' in the program and think its value should be
  884. that of the variable `foo', whereas in fact the value is four
  885. greater.
  886. The special rule for self-reference applies also to "indirect"
  887. self-reference. This is the case where a macro X expands to use a
  888. macro `y', and `y''s expansion refers to the macro `x'. The
  889. resulting reference to `x' comes indirectly from the expansion of
  890. `x', so it is a self-reference and is not further expanded. Thus,
  891. after
  892. #define x (4 + y)
  893. #define y (2 * x)
  894. `x' would expand into `(4 + (2 * x))'. Clear?
  895. But suppose `y' is used elsewhere, not from the definition of `x'.
  896. Then the use of `x' in the expansion of `y' is not a self-reference
  897. because `x' is not "in progress". So it does expand. However,
  898. the expansion of `x' contains a reference to `y', and that
  899. is an indirect self-reference now because `y' is "in progress".
  900. The result is that `y' expands to `(2 * (4 + y))'.
  901. It is not clear that this behavior would ever be useful, but it is specified
  902. by the ANSI C standard, so you need to understand it.
  903. 
  904. File: cpp.info Node: Argument Prescan, Prev: Self-Reference, Up: Macro Pitfalls, Next: Cascaded Macros
  905. Separate Expansion of Macro Arguments
  906. .....................................
  907. We have explained that the expansion of a macro, including the substituted
  908. actual arguments, is scanned over again for macro calls to be expanded.
  909. What really happens is more subtle: first each actual argument text is scanned
  910. separately for macro calls. Then the results of this are substituted into
  911. the macro body to produce the macro expansion, and the macro expansion
  912. is scanned again for macros to expand.
  913. The result is that the actual arguments are scanned *twice* to expand
  914. macro calls in them.
  915. Most of the time, this has no effect. If the actual argument contained
  916. any macro calls, they are expanded during the first scan. The result
  917. therefore contains no macro calls, so the second scan does not change it.
  918. If the actual argument were substituted as given, with no prescan,
  919. the single remaining scan would find the same macro calls and produce
  920. the same results.
  921. You might expect the double scan to change the results when a
  922. self-referential macro is used in an actual argument of another macro
  923. (*Note Self-Reference::): the self-referential macro would be expanded once
  924. in the first scan, and a second time in the second scan. But this is not
  925. what happens. The self-references that do not expand in the first scan are
  926. marked so that they will not expand in the second scan either.
  927. The prescan is not done when an argument is stringified or concatenated.
  928. (More precisely, stringification and concatenation use the argument as
  929. written, in un-prescanned form. The same actual argument would be used in
  930. prescanned form if it is substituted elsewhere without stringification or
  931. concatenation.) Thus,
  932. #define str(s) #s
  933. #define foo 4
  934. str (foo)
  935. expands to `"foo"'. Once more, prescan has been prevented from
  936. having any noticeable effect.
  937. You might now ask, "Why mention the prescan, if it makes no difference?
  938. Why not skip it and make the preprocessor faster?" The answer is that the
  939. prescan does make a difference in two special cases:
  940. * Nested calls to a macro.
  941. * Macros that call other macros that stringify or concatenate.
  942. We say that "nested" calls to a macro occur when a macro's actual
  943. argument contains a call to that very macro. For example, if `f'
  944. is a macro that expects one argument, `f (f (1))' is a nested
  945. pair of calls to `f'. The desired expansion is made by
  946. expanding `f (1)' and substituting that into the definition of
  947. `f'. The prescan causes the expected result to happen.
  948. Without the prescan, `f (1)' itself would be substituted as
  949. an actual argument, and the inner use of `f' would appear
  950. during the main scan as an indirect self-reference and would not
  951. be expanded. Here, the prescan cancels an undesirable side effect
  952. (in the medical, not computational, sense of the term) of the special
  953. rule for self-referential macros.
  954. There is also one case where prescan is useful. It is possible
  955. to use prescan to expand an argument and then stringify it---if you use
  956. two levels of macros. Let's add a new macro `xstr' to the
  957. example shown above:
  958. #define xstr(s) str(s)
  959. #define str(s) #s
  960. #define foo 4
  961. xstr (foo)
  962. This expands into `"4"', not `"foo"'. The reason for the
  963. difference is that the argument of `xstr' is expanded at prescan
  964. (because `xstr' does not specify stringification or concatenation of
  965. the argument). The result of prescan then forms the actual argument for
  966. `str'. `str' uses its argument without prescan because it
  967. performs strigification; but it cannot prevent or undo the prescanning
  968. already done by `xstr'.
  969. 
  970. File: cpp.info Node: Cascaded Macros, Prev: Argument Prescan, Up: Macro Pitfalls
  971. Cascaded Use of Macros
  972. ......................
  973. A "cascade" of macros is when one macro's body contains a reference
  974. to another macro. This is very common practice. For example,
  975. #define BUFSIZE 1020
  976. #define TABLESIZE BUFSIZE
  977. This is not at all the same as defining `TABLESIZE' to be `1020'.
  978. The `#define' for `TABLESIZE' uses exactly the body you
  979. specify---in this case, `BUFSIZE'---and does not check to see whether
  980. it too is the name of a macro.
  981. It's only when you *use* `TABLESIZE' that the result of its expansion
  982. is checked for more macro names.
  983. This makes a difference if you change the definition of `BUFSIZE'
  984. at some point in the source file. `TABLESIZE', defined as shown,
  985. will always expand using the definition of `BUFSIZE' that is
  986. currently in effect:
  987. #define BUFSIZE 1020
  988. #define TABLESIZE BUFSIZE
  989. #undef BUFSIZE
  990. #define BUFSIZE 37
  991. Now `TABLESIZE' expands (in two stages) to `37'.
  992. 
  993. File: cpp.info Node: Conditionals, Prev: Macros, Up: Top, Next: Combining Sources
  994. Conditionals
  995. ============
  996. In a macro processor, a "conditional" is a command that allows a part
  997. of the program to be ignored during compilation, on some conditions.
  998. In the C preprocessor, a conditional can test either an arithmetic expression
  999. or whether a name is defined as a macro.
  1000. A conditional in the C preprocessor resembles in some ways an `if'
  1001. statement in C, but it is important to understand the difference between
  1002. them. The condition in an `if' statement is tested during the execution
  1003. of your program. Its purpose is to allow your program to behave differently
  1004. from run to run, depending on the data it is operating on. The condition
  1005. in a preprocessor conditional command is tested when your program is compiled.
  1006. Its purpose is to allow different code to be included in the program depending
  1007. on the situation at the time of compilation.
  1008. * Menu:
  1009. * Uses: Conditional Uses. What conditionals are for.
  1010. * Syntax: Conditional Syntax. How conditionals are written.
  1011. * Deletion: Deleted Code. Making code into a comment.
  1012. * Macros: Conditionals-Macros. Why conditionals are used with macros.
  1013. * Errors: #error Command. Detecting inconsistent compilation parameters.
  1014. 
  1015. File: cpp.info Node: Conditional Uses, Prev: Conditionals, Up: Conditionals, Next: Conditional Syntax
  1016. Generally there are three kinds of reason to use a conditional.
  1017. * A program may need to use different code depending on the machine or
  1018. operating system it is to run on. In some cases the code for one
  1019. operating system may be erroneous on another operating system; for
  1020. example, it might refer to library routines that do not exist on the
  1021. other system. When this happens, it is not enough to avoid executing
  1022. the invalid code: merely having it in the program makes it impossible
  1023. to link the program and run it. With a preprocessor conditional, the
  1024. offending code can be effectively excised from the program when it is
  1025. not valid.
  1026. * You may want to be able to compile the same source file into two
  1027. different programs. Sometimes the difference between the programs is
  1028. that one makes frequent time-consuming consistency checks on its
  1029. intermediate data while the other does not.
  1030. * A conditional whose condition is always false is a good way to exclude
  1031. code from the program but keep it as a sort of comment for future
  1032. reference.
  1033. Most simple programs that are intended to run on only one machine will
  1034. not need to use preprocessor conditionals.
  1035. 
  1036. File: cpp.info Node: Conditional Syntax, Prev: Conditional Uses, Up: Conditionals, Next: Conditionals-Macros
  1037. Syntax of Conditionals
  1038. ----------------------
  1039. A conditional in the C preprocessor begins with a "conditional
  1040. command": `#if', `#ifdef' or `#ifndef'.*Note Conditionals::,
  1041. for info on `#ifdef' and `#ifndef'; only `#if' is explained
  1042. here.
  1043. * Menu:
  1044. * If: #if Command. Basic conditionals using `#if' and `#endif'.
  1045. * Else: #else Command. Including some text if the condition fails.
  1046. * Elif: #elif Command. Testing several alternative possibilities.
  1047. 
  1048. File: cpp.info Node: #if Command, Prev: Conditional Syntax, Up: Conditional Syntax, Next: #else Command
  1049. The `#if' Command
  1050. .................
  1051. The `#if' command in its simplest form consists of
  1052. #if EXPRESSION
  1053. CONTROLLED TEXT
  1054. #endif /* EXPRESSION */
  1055. The comment following the `#endif' is not required, but it is a good
  1056. practice because it helps people match the `#endif' to the
  1057. corresponding `#if'. Such comments should always be used, except in
  1058. short conditionals that are not nested. In fact, you can put anything at
  1059. all after the `#endif' and it will be ignored by the GNU C preprocessor,
  1060. but only comments are acceptable in ANSI Standard C.
  1061. EXPRESSION is a C expression of integer type, subject to stringent
  1062. restrictions. It may contain
  1063. * Integer constants, which are all regarded as `long' or
  1064. `unsigned long'.
  1065. * Character constants, which are interpreted according to the character
  1066. set and conventions of the machine and operating system on which the
  1067. preprocessor is running. The GNU C preprocessor uses the C data type
  1068. `char' for these character constants; therefore, whether some
  1069. character codes are negative is determined by the C compiler used to
  1070. compile the preprocessor. If it treats `char' as signed, then
  1071. character codes large enough to set the sign bit will be considered
  1072. negative; otherwise, no character code is considered negative.
  1073. * Arithmetic operators for addition, subtraction, multiplication,
  1074. division, bitwise operations, shifts, comparisons, and `&&' and
  1075. `||'.
  1076. * Identifiers that are not macros, which are all treated as zero(!).
  1077. * Macro calls. All macro calls in the expression are expanded before
  1078. actual computation of the expression's value begins.
  1079. Note that `sizeof' operators and `enum'-type values are not allowed.
  1080. `enum'-type values, like all other identifiers that are not taken
  1081. as macro calls and expanded, are treated as zero.
  1082. The text inside of a conditional can include preprocessor commands. Then
  1083. the commands inside the conditional are obeyed only if that branch of the
  1084. conditional succeeds. The text can also contain other conditional groups.
  1085. However, the `#if''s and `#endif''s must balance.
  1086. 
  1087. File: cpp.info Node: #else Command, Prev: #if Command, Up: Conditional Syntax, Next: #elif Command
  1088. The `#else' Command
  1089. ...................
  1090. The `#else' command can be added a conditional to provide alternative
  1091. text to be used if the condition is false. This looks like
  1092. #if EXPRESSION
  1093. TEXT-IF-TRUE
  1094. #else /* Not EXPRESSION */
  1095. TEXT-IF-FALSE
  1096. #endif /* Not EXPRESSION */
  1097. If EXPRESSION is nonzero, and the TEXT-IF-TRUE is considered
  1098. included, then `#else' acts like a failing conditional and the
  1099. TEXT-IF-FALSE is ignored. Contrariwise, if the `#if'
  1100. conditional fails, the TEXT-IF-FALSE is considered included.
  1101. 
  1102. File: cpp.info Node: #elif Command, Prev: #else Command, Up: Conditional Syntax
  1103. The `#elif' Command
  1104. ...................
  1105. One common case of nested conditionals is used to check for more than two
  1106. possible alternatives. For example, you might have
  1107. #if X == 1
  1108. ...
  1109. #else /* X != 1 */
  1110. #if X == 2
  1111. ...
  1112. #else /* X != 2 */
  1113. ...
  1114. #endif /* X != 2 */
  1115. #endif /* X != 1 */
  1116. Another conditional command, `#elif', allows this to be abbreviated
  1117. as follows:
  1118. #if X == 1
  1119. ...
  1120. #elif X == 2
  1121. ...
  1122. #else /* X != 2 and X != 1*/
  1123. ...
  1124. #endif /* X != 2 and X != 1*/
  1125. `#elif' stands for "else if". Like `#else', it goes in the
  1126. middle of a `#if'-`#endif' pair and subdivides it; it does not
  1127. require a matching `#endif' of its own. Like `#if', the
  1128. `#elif' command includes an expression to be tested.
  1129. The text following the `#elif' is processed only if the original
  1130. `#if'-condition failed and the `#elif' condition succeeeds. More
  1131. than one `#elif' can go in the same `#if'-`#endif' group.
  1132. Then the text after each `#elif' is processed only if the `#elif'
  1133. condition succeeds after the original `#if' and any previous
  1134. `#elif''s within it have failed. `#else' is equivalent to
  1135. `#elif 1', and `#else' is allowed after any number of
  1136. `#elif''s, but `#elif' may not follow a `#else'.
  1137. 
  1138. File: cpp.info Node: Deleted Code, Prev: Conditional Syntax, Up: Conditionals, Next: Conditionals-Macros
  1139. Keeping Deleted Code for Future Reference
  1140. -----------------------------------------
  1141. If you replace or delete a part of the program but want to keep the old
  1142. code around as a comment for future reference, the easy way to do this is
  1143. to put `#if 0' before it and `#endif' after it.
  1144. This works even if the code being turned off contains conditionals, but
  1145. they must be entire conditionals (balanced `#if' and `#endif').
  1146. 
  1147. File: cpp.info Node: Conditionals-Macros, Prev: Deleted Code, Up: Conditionals, Next: #error Command
  1148. Conditionals and Macros
  1149. -----------------------
  1150. Conditionals are rarely useful except in connection with macros. A
  1151. `#if' command whose expression uses no macros is equivalent to
  1152. `#if 1' or `#if 0'; you might as well determine which one, by
  1153. computing the value of the expression yourself, and then simplify the
  1154. program. But when the expression uses macros, its value can vary from
  1155. compilation to compilation.
  1156. For example, here is a conditional that tests the expression
  1157. `BUFSIZE == 1020', where `BUFSIZE' must be a macro.
  1158. #if BUFSIZE == 1020
  1159. printf ("Large buffers!\n");
  1160. #endif /* BUFSIZE is large */
  1161. The special operator `defined' may be used in `#if' expressions to test
  1162. whether a certain name is defined as a macro. Either `defined NAME' or
  1163. `defined (NAME)' is an expression whose value is 1 if NAME is defined as
  1164. macro at the current point in the program, and 0 otherwise. For the
  1165. `defined' operator it makes no difference what the definition of the macro
  1166. is; all that matters is whether there is a definition. Thus, for example,
  1167. #if defined (vax) || defined (ns16000)
  1168. would include the following code if either of the names `vax' and
  1169. `ns16000' is defined as a macro.
  1170. If a macro is defined and later undefined with `#undef',
  1171. subsequent use of the `defined' operator will return 0, because
  1172. the name is no longer defined. If the macro is defined again with
  1173. another `#define', `defined' will recommence returning 1.
  1174. Conditionals that test just the definedness of one name are very common, so
  1175. there are two special short conditional commands for this case. They are
  1176. `#ifdef NAME'
  1177. is equivalent to `#if defined (NAME)'.
  1178. `#ifndef NAME'
  1179. is equivalent to `#if ! defined (NAME)'.
  1180. Macro definitions can vary between compilations for several reasons.
  1181. * Some macros are predefined on each kind of machine. For example, on a
  1182. Vax, the name `vax' is a predefined macro. On other machines, it
  1183. would not be defined.
  1184. * Many more macros are defined by system header files. Different
  1185. systems and machines define different macros, or give them different
  1186. values. It is useful to test these macros with conditionals to avoid
  1187. using a system feature on a machine where it is not implemented.
  1188. * Macros are a common way of allowing users to customize a program for
  1189. different machines or applications. For example, the macro
  1190. `BUFSIZE' might be defined in a configuration file for your
  1191. program that is included as a header file in each source file. You
  1192. would use `BUFSIZE' in a preprocessor conditional in order to
  1193. generate different code depending on the chosen configuration.
  1194. * Macros can be defined or undefined with `-D' and `-U'
  1195. command options when you compile the program. You can arrange to
  1196. compile the same source file into two different programs by choosing
  1197. a macro name to specify which program you want, writing conditionals
  1198. to test whether or how this macro is defined, and then controlling
  1199. the state of the macro with compiler command options.
  1200. *Note Invocation::.
  1201. 
  1202. File: cpp.info Node: #error Command, Prev: Conditionals-Macros, Up: Conditionals
  1203. The `#error' Command
  1204. --------------------
  1205. The command `#error' causes the preprocessor to report a fatal
  1206. error. The rest of the line that follows `#error' is used as the
  1207. error message.
  1208. You would use `#error' inside of a conditional that detects a
  1209. combination of parameters which you know the program does not properly
  1210. support. For example, if you know that the program will not run
  1211. properly on a Vax, you might write
  1212. #ifdef vax
  1213. #error Won't work on Vaxen. See comments at get_last_object.
  1214. #endif
  1215. *Note Nonstandard Predefined::, for why this works.
  1216. If you have several configuration parameters that must be set up by
  1217. the installation in a consistent way, you can use conditionals to detect
  1218. an inconsistency and report it with `#error'. For example,
  1219. #if HASH_TABLE_SIZE % 2 == 0 || HASH_TABLE_SIZE % 3 == 0 \
  1220. || HASH_TABLE_SIZE % 5 == 0
  1221. #error HASH_TABLE_SIZE should not be divisible by a small prime
  1222. #endif
  1223. 
  1224. File: cpp.info Node: Combining Sources, Prev: Conditionals, Up: Top, Next: Other Commands
  1225. Combining Source Files
  1226. ======================
  1227. One of the jobs of the C preprocessor is to inform the C compiler of where
  1228. each line of C code came from: which source file and which line number.
  1229. C code can come from multiple source files if you use `#include';
  1230. both `#include' and the use of conditionals and macros can cause
  1231. the line number of a line in the preprocessor output to be different
  1232. from the line's number in the original source file. You will appreciate
  1233. the value of making both the C compiler (in error messages) and symbolic
  1234. debuggers such as GDB use the line numbers in your source file.
  1235. The C preprocessor builds on this feature by offering a command by which
  1236. you can control the feature explicitly. This is useful when a file for
  1237. input to the C preprocessor is the output from another program such as the
  1238. `bison' parser generator, which operates on another file that is the
  1239. true source file. Parts of the output from `bison' are generated from
  1240. scratch, other parts come from a standard parser file. The rest are copied
  1241. nearly verbatim from the source file, but their line numbers in the
  1242. `bison' output are not the same as their original line numbers.
  1243. Naturally you would like compiler error messages and symbolic debuggers to
  1244. know the original source file and line number of each line in the
  1245. `bison' output.
  1246. `bison' arranges this by writing `#line' commands into the output
  1247. file. `#line' is a command that specifies the original line number
  1248. and source file name for subsequent input in the current preprocessor input
  1249. file. `#line' has three variants:
  1250. `#line LINENUM'
  1251. Here LINENUM is a decimal integer constant. This specifies that
  1252. the line number of the following line of input, in its original source file,
  1253. was LINENUM.
  1254. `#line LINENUM FILENAME'
  1255. Here LINENUM is a decimal integer constant and FILENAME
  1256. is a string constant. This specifies that the following line of input
  1257. came originally from source file FILENAME and its line number there
  1258. was LINENUM. Keep in mind that FILENAME is not just a
  1259. file name; it is surrounded by doublequote characters so that it looks
  1260. like a string constant.
  1261. `#line ANYTHING ELSE'
  1262. ANYTHING ELSE is checked for macro calls, which are expanded.
  1263. The result should be a decimal integer constant followed optionally
  1264. by a string constant, as described above.
  1265. `#line' commands alter the results of the `__FILE__' and
  1266. `__LINE__' predefined macros from that point on. *Note Standard Predefined::.
  1267. 
  1268. File: cpp.info Node: Other Commands, Prev: Combining Sources, Up: Top, Next: Output
  1269. Miscellaneous Preprocessor Commands
  1270. ===================================
  1271. This section describes two additional preprocesor commands. They are
  1272. not very useful, but are mentioned for completeness.
  1273. The "null command" consists of a `#' followed by a Newline, with
  1274. only whitespace (including comments) in between. A null command is
  1275. understood as a preprocessor command but has no effect on the preprocessor
  1276. output. The primary significance of the existence of the null command is
  1277. that an input line consisting of just a `#' will produce no output,
  1278. rather than a line of output containing just a `#'. Supposedly
  1279. some old C programs contain such lines.
  1280. The `#pragma' command is specified in the ANSI standard to have an
  1281. arbitrary implementation-defined effect. In the GNU C preprocessor,
  1282. `#pragma' first attempts to run the game `rogue'; if that fails,
  1283. it tries to run the game `hack'; if that fails, it tries to run
  1284. GNU Emacs displaying the Tower of Hanoi; if that fails, it reports a
  1285. fatal error. In any case, preprocessing does not continue.
  1286. 
  1287. File: cpp.info Node: Output, Prev: Other Commands, Up: Top, Next: Invocation
  1288. C Preprocessor Output
  1289. =====================
  1290. The output from the C preprocessor looks much like the input, except
  1291. that all preprocessor command lines have been replaced with blank lines
  1292. and all comments with spaces. Whitespace within a line is not altered;
  1293. however, a space is inserted after the expansions of most macro calls.
  1294. Source file name and line number information is conveyed by lines of
  1295. the form
  1296. # LINENUM FILENAME
  1297. which are inserted as needed into the middle of the input (but never within
  1298. a string or character constant). Such a line means that the following line
  1299. originated in file FILENAME at line LINENUM.
  1300. 
  1301. File: cpp.info Node: Invocation, Prev: Output, Up: Top
  1302. Invoking the C Preprocessor
  1303. ===========================
  1304. Most often when you use the C preprocessor you will not have to invoke it
  1305. explicitly: the C compiler will do so automatically. However, the
  1306. preprocessor is sometimes useful individually.
  1307. The C preprocessor expects two file names as arguments, INFILE and
  1308. OUTFILE. The preprocessor reads INFILE together with any other
  1309. files it specifies with `#include'. All the output generated by the
  1310. combined input files is written in OUTFILE.
  1311. Either INFILE or OUTFILE may be `-', which as INFILE
  1312. means to read from standard input and as OUTFILE means to write to
  1313. standard output. Also, if OUTFILE or both file names are omitted,
  1314. the standard output and standard input are used for the omitted file names.
  1315. Here is a table of command options accepted by the C preprocessor. Most
  1316. of them can also be given when compiling a C program; they are passed along
  1317. automatically to the preprocessor when it is invoked by the compiler.
  1318. `-P'
  1319. Inhibit generation of `#'-lines with line-number information in
  1320. the output from the preprocessor (*Note Output::). This might be
  1321. useful when running the preprocessor on something that is not C code
  1322. and will be sent to a program which might be confused by the
  1323. `#'-lines
  1324. `-C'
  1325. Do not discard comments: pass them through to the output file.
  1326. Comments appearing in arguments of a macro call will be copied to the
  1327. output before the expansion of the macro call.
  1328. `-T'
  1329. Process ANSI standard trigraph sequences. These are three-character
  1330. sequences, all starting with `??', that are defined by ANSI C to
  1331. stand for single characters. For example, `??/' stands for
  1332. `\', so `'??/n'' is a character constant for Newline.
  1333. Strictly speaking, the GNU C preprocessor does not support all
  1334. programs in ANSI Standard C unless `-T' is used, but if you
  1335. ever notice the difference it will be with relief.
  1336. You don't want to know any more about trigraphs.
  1337. `-pedantic'
  1338. Issue warnings required by the ANSI C standard in certain cases such
  1339. as when text other than a comment follows `#else' or `#endif'.
  1340. `-I DIRECTORY'
  1341. Add the directory DIRECTORY to the end of the list of
  1342. directories to be searched for header files (*Note Include Syntax::).
  1343. This can be used to override a system header file, substituting your
  1344. own version, since these directories are searched before the system
  1345. header file directories. If you use more than one `-I' option,
  1346. the directories are scanned in left-to-right order; the standard
  1347. system directories come after.
  1348. `-D NAME'
  1349. Predefine NAME as a macro, with definition `1'.
  1350. `-D NAME=DEFINITION'
  1351. Predefine NAME as a macro, with definition DEFINITION.
  1352. There are no restrictions on the contents of DEFINITION, but if
  1353. you are invoking the preprocessor from a shell or shell-like program
  1354. you may need to use the shell's quoting syntax to protect characters
  1355. such as spaces that have a meaning in the shell syntax.
  1356. `-U NAME'
  1357. Do not predefine NAME. If both `-U' and `-D' are
  1358. specified for one name, the `-U' beats the `-D' and the name
  1359. is not predefined.
  1360. `-undef'
  1361. Do not predefine any nonstandard macros.
  1362. `-d'
  1363. Instead of outputting the result of preprocessing, output a list of
  1364. `#define' commands for all the macros defined during the
  1365. execution of the preprocessor.
  1366. `-M'
  1367. Instead of outputting the result of preprocessing, output a rule
  1368. suitable for `make' describing the dependencies of the main
  1369. source file. The preprocessor outputs one `make' rule containing
  1370. the object file name for that source file, a colon, and the names of
  1371. all the included files. If there are many included files then the
  1372. rule is split into several lines using `\'-newline.
  1373. This feature is used in automatic updating of makefiles.
  1374. `-MM'
  1375. Like `-M' but mention only the files included with `#include
  1376. "FILE"'. System header files included with `#include
  1377. <FILE>' are omitted.
  1378. `-i FILE'
  1379. Process FILE as input, discarding the resulting output, before
  1380. processing the regular input file. Because the output generated from
  1381. FILE is discarded, the only effect of `-i FILE' is to
  1382. make the macros defined in FILE available for use in the main
  1383. input.
  1384. 
  1385. File: cpp.info Node: Concept Index, Prev: Invocation, Up: Top, Next: Index
  1386. Concept Index
  1387. *************
  1388. * Menu:
  1389. * cascaded macros: Cascaded Macros.
  1390. * commands: Commands.
  1391. * concatenation: Concatenation.
  1392. * conditionals: Conditionals.
  1393. * header file: Header Files.
  1394. * line control: Combining Sources.
  1395. * macro body uses macro: Cascaded Macros.
  1396. * null command: Other Commands.
  1397. * options: Invocation.
  1398. * output format: Output.
  1399. * predefined macros: Predefined.
  1400. * preprocessor commands: Commands.
  1401. * redefining macros: Redefining.
  1402. * self-reference: Self-Reference.
  1403. * semicolons (after macro calls): Swallow Semicolon.
  1404. * side effects (in macro arguments): Side Effects.
  1405. * stringification: Stringification.
  1406. * undefining macros: Undefining.
  1407. * unsafe macros: Side Effects.
  1408. 
  1409. File: cpp.info Node: Index, Prev: Concept Index, Up: Top
  1410. Index of Commands, Macros and Options
  1411. *************************************
  1412. * Menu:
  1413. * BSD: Nonstandard Predefined.
  1414. * -C: Invocation.
  1415. * -D: Invocation.
  1416. * -d: Invocation.
  1417. * __DATE__: Standard Predefined.
  1418. * defined: Conditionals-Macros.
  1419. * #elif: #elif Command.
  1420. * #else: #else Command.
  1421. * #error: #error Command.
  1422. * __FILE__: Standard Predefined.
  1423. * -I: Invocation.
  1424. * -i: Invocation.
  1425. * #if: Conditional Syntax.
  1426. * #ifdef: Conditionals-Macros.
  1427. * #ifndef: Conditionals-Macros.
  1428. * #include: Include Syntax.
  1429. * #line: Combining Sources.
  1430. * __LINE__: Standard Predefined.
  1431. * -M: Invocation.
  1432. * M68020: Nonstandard Predefined.
  1433. * m68k: Nonstandard Predefined.
  1434. * mc68000: Nonstandard Predefined.
  1435. * -MM: Invocation.
  1436. * ns32000: Nonstandard Predefined.
  1437. * -P: Invocation.
  1438. * -pedantic: Invocation.
  1439. * #pragma: Other Commands.
  1440. * pyr: Nonstandard Predefined.
  1441. * sequent: Nonstandard Predefined.
  1442. * __STDC__: Standard Predefined.
  1443. * sun: Nonstandard Predefined.
  1444. * system header files: Header Uses.
  1445. * -T: Invocation.
  1446. * __TIME__: Standard Predefined.
  1447. * -U: Invocation.
  1448. * -undef: Invocation.
  1449. * unix: Nonstandard Predefined.
  1450. * vax: Nonstandard Predefined.
  1451. 
  1452. Tag table:
  1453. Node: Top742
  1454. Node: Global Actions3291
  1455. Node: Commands5797
  1456. Node: Header Files7393
  1457. Node: Header Uses7728
  1458. Node: Include Syntax9114
  1459. Node: Include Operation11866
  1460. Node: Macros13510
  1461. Node: Simple Macros14417
  1462. Node: Argument Macros17455
  1463. Node: Predefined22546
  1464. Node: Standard Predefined22969
  1465. Node: Nonstandard Predefined27054
  1466. Node: Stringification29853
  1467. Node: Concatenation32685
  1468. Node: Undefining35937
  1469. Node: Redefining36954
  1470. Node: Macro Pitfalls38238
  1471. Node: Misnesting39278
  1472. Node: Macro Parentheses40279
  1473. Node: Swallow Semicolon42126
  1474. Node: Side Effects44012
  1475. Node: Self-Reference45694
  1476. Node: Argument Prescan47932
  1477. Node: Cascaded Macros51637
  1478. Node: Conditionals52654
  1479. Node: Conditional Uses53935
  1480. Node: Conditional Syntax55267
  1481. Node: #if Command55829
  1482. Node: #else Command58086
  1483. Node: #elif Command58724
  1484. Node: Deleted Code60059
  1485. Node: Conditionals-Macros60585
  1486. Node: #error Command63826
  1487. Node: Combining Sources64867
  1488. Node: Other Commands67499
  1489. Node: Output68634
  1490. Node: Invocation69347
  1491. Node: Concept Index73904
  1492. Node: Index74667
  1493. 
  1494. End tag table