cpp.info 226 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358
  1. This is cpp.info, produced by makeinfo version 5.2 from cpp.texi.
  2. Copyright (C) 1987-2017 Free Software Foundation, Inc.
  3. Permission is granted to copy, distribute and/or modify this document
  4. under the terms of the GNU Free Documentation License, Version 1.3 or
  5. any later version published by the Free Software Foundation. A copy of
  6. the license is included in the section entitled "GNU Free Documentation
  7. License".
  8. This manual contains no Invariant Sections. The Front-Cover Texts
  9. are (a) (see below), and the Back-Cover Texts are (b) (see below).
  10. (a) The FSF's Front-Cover Text is:
  11. A GNU Manual
  12. (b) The FSF's Back-Cover Text is:
  13. You have freedom to copy and modify this GNU Manual, like GNU
  14. software. Copies published by the Free Software Foundation raise funds
  15. for GNU development.
  16. INFO-DIR-SECTION Software development
  17. START-INFO-DIR-ENTRY
  18. * Cpp: (cpp). The GNU C preprocessor.
  19. END-INFO-DIR-ENTRY
  20. 
  21. File: cpp.info, Node: Top, Next: Overview, Up: (dir)
  22. The C Preprocessor
  23. ******************
  24. The C preprocessor implements the macro language used to transform C,
  25. C++, and Objective-C programs before they are compiled. It can also be
  26. useful on its own.
  27. * Menu:
  28. * Overview::
  29. * Header Files::
  30. * Macros::
  31. * Conditionals::
  32. * Diagnostics::
  33. * Line Control::
  34. * Pragmas::
  35. * Other Directives::
  36. * Preprocessor Output::
  37. * Traditional Mode::
  38. * Implementation Details::
  39. * Invocation::
  40. * Environment Variables::
  41. * GNU Free Documentation License::
  42. * Index of Directives::
  43. * Option Index::
  44. * Concept Index::
  45. -- The Detailed Node Listing --
  46. Overview
  47. * Character sets::
  48. * Initial processing::
  49. * Tokenization::
  50. * The preprocessing language::
  51. Header Files
  52. * Include Syntax::
  53. * Include Operation::
  54. * Search Path::
  55. * Once-Only Headers::
  56. * Alternatives to Wrapper #ifndef::
  57. * Computed Includes::
  58. * Wrapper Headers::
  59. * System Headers::
  60. Macros
  61. * Object-like Macros::
  62. * Function-like Macros::
  63. * Macro Arguments::
  64. * Stringizing::
  65. * Concatenation::
  66. * Variadic Macros::
  67. * Predefined Macros::
  68. * Undefining and Redefining Macros::
  69. * Directives Within Macro Arguments::
  70. * Macro Pitfalls::
  71. Predefined Macros
  72. * Standard Predefined Macros::
  73. * Common Predefined Macros::
  74. * System-specific Predefined Macros::
  75. * C++ Named Operators::
  76. Macro Pitfalls
  77. * Misnesting::
  78. * Operator Precedence Problems::
  79. * Swallowing the Semicolon::
  80. * Duplication of Side Effects::
  81. * Self-Referential Macros::
  82. * Argument Prescan::
  83. * Newlines in Arguments::
  84. Conditionals
  85. * Conditional Uses::
  86. * Conditional Syntax::
  87. * Deleted Code::
  88. Conditional Syntax
  89. * Ifdef::
  90. * If::
  91. * Defined::
  92. * Else::
  93. * Elif::
  94. Implementation Details
  95. * Implementation-defined behavior::
  96. * Implementation limits::
  97. * Obsolete Features::
  98. Obsolete Features
  99. * Obsolete Features::
  100. Copyright (C) 1987-2017 Free Software Foundation, Inc.
  101. Permission is granted to copy, distribute and/or modify this document
  102. under the terms of the GNU Free Documentation License, Version 1.3 or
  103. any later version published by the Free Software Foundation. A copy of
  104. the license is included in the section entitled "GNU Free Documentation
  105. License".
  106. This manual contains no Invariant Sections. The Front-Cover Texts
  107. are (a) (see below), and the Back-Cover Texts are (b) (see below).
  108. (a) The FSF's Front-Cover Text is:
  109. A GNU Manual
  110. (b) The FSF's Back-Cover Text is:
  111. You have freedom to copy and modify this GNU Manual, like GNU
  112. software. Copies published by the Free Software Foundation raise funds
  113. for GNU development.
  114. 
  115. File: cpp.info, Node: Overview, Next: Header Files, Prev: Top, Up: Top
  116. 1 Overview
  117. **********
  118. The C preprocessor, often known as "cpp", is a "macro processor" that is
  119. used automatically by the C compiler to transform your program before
  120. compilation. It is called a macro processor because it allows you to
  121. define "macros", which are brief abbreviations for longer constructs.
  122. The C preprocessor is intended to be used only with C, C++, and
  123. Objective-C source code. In the past, it has been abused as a general
  124. text processor. It will choke on input which does not obey C's lexical
  125. rules. For example, apostrophes will be interpreted as the beginning of
  126. character constants, and cause errors. Also, you cannot rely on it
  127. preserving characteristics of the input which are not significant to
  128. C-family languages. If a Makefile is preprocessed, all the hard tabs
  129. will be removed, and the Makefile will not work.
  130. Having said that, you can often get away with using cpp on things
  131. which are not C. Other Algol-ish programming languages are often safe
  132. (Pascal, Ada, etc.) So is assembly, with caution. '-traditional-cpp'
  133. mode preserves more white space, and is otherwise more permissive. Many
  134. of the problems can be avoided by writing C or C++ style comments
  135. instead of native language comments, and keeping macros simple.
  136. Wherever possible, you should use a preprocessor geared to the
  137. language you are writing in. Modern versions of the GNU assembler have
  138. macro facilities. Most high level programming languages have their own
  139. conditional compilation and inclusion mechanism. If all else fails, try
  140. a true general text processor, such as GNU M4.
  141. C preprocessors vary in some details. This manual discusses the GNU
  142. C preprocessor, which provides a small superset of the features of ISO
  143. Standard C. In its default mode, the GNU C preprocessor does not do a
  144. few things required by the standard. These are features which are
  145. rarely, if ever, used, and may cause surprising changes to the meaning
  146. of a program which does not expect them. To get strict ISO Standard C,
  147. you should use the '-std=c90', '-std=c99' or '-std=c11' options,
  148. depending on which version of the standard you want. To get all the
  149. mandatory diagnostics, you must also use '-pedantic'. *Note
  150. Invocation::.
  151. This manual describes the behavior of the ISO preprocessor. To
  152. minimize gratuitous differences, where the ISO preprocessor's behavior
  153. does not conflict with traditional semantics, the traditional
  154. preprocessor should behave the same way. The various differences that
  155. do exist are detailed in the section *note Traditional Mode::.
  156. For clarity, unless noted otherwise, references to 'CPP' in this
  157. manual refer to GNU CPP.
  158. * Menu:
  159. * Character sets::
  160. * Initial processing::
  161. * Tokenization::
  162. * The preprocessing language::
  163. 
  164. File: cpp.info, Node: Character sets, Next: Initial processing, Up: Overview
  165. 1.1 Character sets
  166. ==================
  167. Source code character set processing in C and related languages is
  168. rather complicated. The C standard discusses two character sets, but
  169. there are really at least four.
  170. The files input to CPP might be in any character set at all. CPP's
  171. very first action, before it even looks for line boundaries, is to
  172. convert the file into the character set it uses for internal processing.
  173. That set is what the C standard calls the "source" character set. It
  174. must be isomorphic with ISO 10646, also known as Unicode. CPP uses the
  175. UTF-8 encoding of Unicode.
  176. The character sets of the input files are specified using the
  177. '-finput-charset=' option.
  178. All preprocessing work (the subject of the rest of this manual) is
  179. carried out in the source character set. If you request textual output
  180. from the preprocessor with the '-E' option, it will be in UTF-8.
  181. After preprocessing is complete, string and character constants are
  182. converted again, into the "execution" character set. This character set
  183. is under control of the user; the default is UTF-8, matching the source
  184. character set. Wide string and character constants have their own
  185. character set, which is not called out specifically in the standard.
  186. Again, it is under control of the user. The default is UTF-16 or
  187. UTF-32, whichever fits in the target's 'wchar_t' type, in the target
  188. machine's byte order.(1) Octal and hexadecimal escape sequences do not
  189. undergo conversion; '\x12' has the value 0x12 regardless of the
  190. currently selected execution character set. All other escapes are
  191. replaced by the character in the source character set that they
  192. represent, then converted to the execution character set, just like
  193. unescaped characters.
  194. In identifiers, characters outside the ASCII range can only be
  195. specified with the '\u' and '\U' escapes, not used directly. If strict
  196. ISO C90 conformance is specified with an option such as '-std=c90', or
  197. '-fno-extended-identifiers' is used, then those escapes are not
  198. permitted in identifiers.
  199. ---------- Footnotes ----------
  200. (1) UTF-16 does not meet the requirements of the C standard for a
  201. wide character set, but the choice of 16-bit 'wchar_t' is enshrined in
  202. some system ABIs so we cannot fix this.
  203. 
  204. File: cpp.info, Node: Initial processing, Next: Tokenization, Prev: Character sets, Up: Overview
  205. 1.2 Initial processing
  206. ======================
  207. The preprocessor performs a series of textual transformations on its
  208. input. These happen before all other processing. Conceptually, they
  209. happen in a rigid order, and the entire file is run through each
  210. transformation before the next one begins. CPP actually does them all
  211. at once, for performance reasons. These transformations correspond
  212. roughly to the first three "phases of translation" described in the C
  213. standard.
  214. 1. The input file is read into memory and broken into lines.
  215. Different systems use different conventions to indicate the end of
  216. a line. GCC accepts the ASCII control sequences 'LF', 'CR LF' and
  217. 'CR' as end-of-line markers. These are the canonical sequences
  218. used by Unix, DOS and VMS, and the classic Mac OS (before OSX)
  219. respectively. You may therefore safely copy source code written on
  220. any of those systems to a different one and use it without
  221. conversion. (GCC may lose track of the current line number if a
  222. file doesn't consistently use one convention, as sometimes happens
  223. when it is edited on computers with different conventions that
  224. share a network file system.)
  225. If the last line of any input file lacks an end-of-line marker, the
  226. end of the file is considered to implicitly supply one. The C
  227. standard says that this condition provokes undefined behavior, so
  228. GCC will emit a warning message.
  229. 2. If trigraphs are enabled, they are replaced by their corresponding
  230. single characters. By default GCC ignores trigraphs, but if you
  231. request a strictly conforming mode with the '-std' option, or you
  232. specify the '-trigraphs' option, then it converts them.
  233. These are nine three-character sequences, all starting with '??',
  234. that are defined by ISO C to stand for single characters. They
  235. permit obsolete systems that lack some of C's punctuation to use C.
  236. For example, '??/' stands for '\', so '??/n' is a character
  237. constant for a newline.
  238. Trigraphs are not popular and many compilers implement them
  239. incorrectly. Portable code should not rely on trigraphs being
  240. either converted or ignored. With '-Wtrigraphs' GCC will warn you
  241. when a trigraph may change the meaning of your program if it were
  242. converted. *Note Wtrigraphs::.
  243. In a string constant, you can prevent a sequence of question marks
  244. from being confused with a trigraph by inserting a backslash
  245. between the question marks, or by separating the string literal at
  246. the trigraph and making use of string literal concatenation.
  247. "(??\?)" is the string '(???)', not '(?]'. Traditional C compilers
  248. do not recognize these idioms.
  249. The nine trigraphs and their replacements are
  250. Trigraph: ??( ??) ??< ??> ??= ??/ ??' ??! ??-
  251. Replacement: [ ] { } # \ ^ | ~
  252. 3. Continued lines are merged into one long line.
  253. A continued line is a line which ends with a backslash, '\'. The
  254. backslash is removed and the following line is joined with the
  255. current one. No space is inserted, so you may split a line
  256. anywhere, even in the middle of a word. (It is generally more
  257. readable to split lines only at white space.)
  258. The trailing backslash on a continued line is commonly referred to
  259. as a "backslash-newline".
  260. If there is white space between a backslash and the end of a line,
  261. that is still a continued line. However, as this is usually the
  262. result of an editing mistake, and many compilers will not accept it
  263. as a continued line, GCC will warn you about it.
  264. 4. All comments are replaced with single spaces.
  265. There are two kinds of comments. "Block comments" begin with '/*'
  266. and continue until the next '*/'. Block comments do not nest:
  267. /* this is /* one comment */ text outside comment
  268. "Line comments" begin with '//' and continue to the end of the
  269. current line. Line comments do not nest either, but it does not
  270. matter, because they would end in the same place anyway.
  271. // this is // one comment
  272. text outside comment
  273. It is safe to put line comments inside block comments, or vice versa.
  274. /* block comment
  275. // contains line comment
  276. yet more comment
  277. */ outside comment
  278. // line comment /* contains block comment */
  279. But beware of commenting out one end of a block comment with a line
  280. comment.
  281. // l.c. /* block comment begins
  282. oops! this isn't a comment anymore */
  283. Comments are not recognized within string literals. "/* blah */" is
  284. the string constant '/* blah */', not an empty string.
  285. Line comments are not in the 1989 edition of the C standard, but they
  286. are recognized by GCC as an extension. In C++ and in the 1999 edition
  287. of the C standard, they are an official part of the language.
  288. Since these transformations happen before all other processing, you
  289. can split a line mechanically with backslash-newline anywhere. You can
  290. comment out the end of a line. You can continue a line comment onto the
  291. next line with backslash-newline. You can even split '/*', '*/', and
  292. '//' onto multiple lines with backslash-newline. For example:
  293. /\
  294. *
  295. */ # /*
  296. */ defi\
  297. ne FO\
  298. O 10\
  299. 20
  300. is equivalent to '#define FOO 1020'. All these tricks are extremely
  301. confusing and should not be used in code intended to be readable.
  302. There is no way to prevent a backslash at the end of a line from
  303. being interpreted as a backslash-newline. This cannot affect any
  304. correct program, however.
  305. 
  306. File: cpp.info, Node: Tokenization, Next: The preprocessing language, Prev: Initial processing, Up: Overview
  307. 1.3 Tokenization
  308. ================
  309. After the textual transformations are finished, the input file is
  310. converted into a sequence of "preprocessing tokens". These mostly
  311. correspond to the syntactic tokens used by the C compiler, but there are
  312. a few differences. White space separates tokens; it is not itself a
  313. token of any kind. Tokens do not have to be separated by white space,
  314. but it is often necessary to avoid ambiguities.
  315. When faced with a sequence of characters that has more than one
  316. possible tokenization, the preprocessor is greedy. It always makes each
  317. token, starting from the left, as big as possible before moving on to
  318. the next token. For instance, 'a+++++b' is interpreted as
  319. 'a ++ ++ + b', not as 'a ++ + ++ b', even though the latter tokenization
  320. could be part of a valid C program and the former could not.
  321. Once the input file is broken into tokens, the token boundaries never
  322. change, except when the '##' preprocessing operator is used to paste
  323. tokens together. *Note Concatenation::. For example,
  324. #define foo() bar
  325. foo()baz
  326. ==> bar baz
  327. _not_
  328. ==> barbaz
  329. The compiler does not re-tokenize the preprocessor's output. Each
  330. preprocessing token becomes one compiler token.
  331. Preprocessing tokens fall into five broad classes: identifiers,
  332. preprocessing numbers, string literals, punctuators, and other. An
  333. "identifier" is the same as an identifier in C: any sequence of letters,
  334. digits, or underscores, which begins with a letter or underscore.
  335. Keywords of C have no significance to the preprocessor; they are
  336. ordinary identifiers. You can define a macro whose name is a keyword,
  337. for instance. The only identifier which can be considered a
  338. preprocessing keyword is 'defined'. *Note Defined::.
  339. This is mostly true of other languages which use the C preprocessor.
  340. However, a few of the keywords of C++ are significant even in the
  341. preprocessor. *Note C++ Named Operators::.
  342. In the 1999 C standard, identifiers may contain letters which are not
  343. part of the "basic source character set", at the implementation's
  344. discretion (such as accented Latin letters, Greek letters, or Chinese
  345. ideograms). This may be done with an extended character set, or the
  346. '\u' and '\U' escape sequences. GCC only accepts such characters in the
  347. '\u' and '\U' forms.
  348. As an extension, GCC treats '$' as a letter. This is for
  349. compatibility with some systems, such as VMS, where '$' is commonly used
  350. in system-defined function and object names. '$' is not a letter in
  351. strictly conforming mode, or if you specify the '-$' option. *Note
  352. Invocation::.
  353. A "preprocessing number" has a rather bizarre definition. The
  354. category includes all the normal integer and floating point constants
  355. one expects of C, but also a number of other things one might not
  356. initially recognize as a number. Formally, preprocessing numbers begin
  357. with an optional period, a required decimal digit, and then continue
  358. with any sequence of letters, digits, underscores, periods, and
  359. exponents. Exponents are the two-character sequences 'e+', 'e-', 'E+',
  360. 'E-', 'p+', 'p-', 'P+', and 'P-'. (The exponents that begin with 'p' or
  361. 'P' are used for hexadecimal floating-point constants.)
  362. The purpose of this unusual definition is to isolate the preprocessor
  363. from the full complexity of numeric constants. It does not have to
  364. distinguish between lexically valid and invalid floating-point numbers,
  365. which is complicated. The definition also permits you to split an
  366. identifier at any position and get exactly two tokens, which can then be
  367. pasted back together with the '##' operator.
  368. It's possible for preprocessing numbers to cause programs to be
  369. misinterpreted. For example, '0xE+12' is a preprocessing number which
  370. does not translate to any valid numeric constant, therefore a syntax
  371. error. It does not mean '0xE + 12', which is what you might have
  372. intended.
  373. "String literals" are string constants, character constants, and
  374. header file names (the argument of '#include').(1) String constants and
  375. character constants are straightforward: "..." or '...'. In either case
  376. embedded quotes should be escaped with a backslash: '\'' is the
  377. character constant for '''. There is no limit on the length of a
  378. character constant, but the value of a character constant that contains
  379. more than one character is implementation-defined. *Note Implementation
  380. Details::.
  381. Header file names either look like string constants, "...", or are
  382. written with angle brackets instead, <...>. In either case, backslash
  383. is an ordinary character. There is no way to escape the closing quote
  384. or angle bracket. The preprocessor looks for the header file in
  385. different places depending on which form you use. *Note Include
  386. Operation::.
  387. No string literal may extend past the end of a line. You may use
  388. continued lines instead, or string constant concatenation.
  389. "Punctuators" are all the usual bits of punctuation which are
  390. meaningful to C and C++. All but three of the punctuation characters in
  391. ASCII are C punctuators. The exceptions are '@', '$', and '`'. In
  392. addition, all the two- and three-character operators are punctuators.
  393. There are also six "digraphs", which the C++ standard calls "alternative
  394. tokens", which are merely alternate ways to spell other punctuators.
  395. This is a second attempt to work around missing punctuation in obsolete
  396. systems. It has no negative side effects, unlike trigraphs, but does
  397. not cover as much ground. The digraphs and their corresponding normal
  398. punctuators are:
  399. Digraph: <% %> <: :> %: %:%:
  400. Punctuator: { } [ ] # ##
  401. Any other single character is considered "other". It is passed on to
  402. the preprocessor's output unmolested. The C compiler will almost
  403. certainly reject source code containing "other" tokens. In ASCII, the
  404. only other characters are '@', '$', '`', and control characters other
  405. than NUL (all bits zero). (Note that '$' is normally considered a
  406. letter.) All characters with the high bit set (numeric range 0x7F-0xFF)
  407. are also "other" in the present implementation. This will change when
  408. proper support for international character sets is added to GCC.
  409. NUL is a special case because of the high probability that its
  410. appearance is accidental, and because it may be invisible to the user
  411. (many terminals do not display NUL at all). Within comments, NULs are
  412. silently ignored, just as any other character would be. In running
  413. text, NUL is considered white space. For example, these two directives
  414. have the same meaning.
  415. #define X^@1
  416. #define X 1
  417. (where '^@' is ASCII NUL). Within string or character constants, NULs
  418. are preserved. In the latter two cases the preprocessor emits a warning
  419. message.
  420. ---------- Footnotes ----------
  421. (1) The C standard uses the term "string literal" to refer only to
  422. what we are calling "string constants".
  423. 
  424. File: cpp.info, Node: The preprocessing language, Prev: Tokenization, Up: Overview
  425. 1.4 The preprocessing language
  426. ==============================
  427. After tokenization, the stream of tokens may simply be passed straight
  428. to the compiler's parser. However, if it contains any operations in the
  429. "preprocessing language", it will be transformed first. This stage
  430. corresponds roughly to the standard's "translation phase 4" and is what
  431. most people think of as the preprocessor's job.
  432. The preprocessing language consists of "directives" to be executed
  433. and "macros" to be expanded. Its primary capabilities are:
  434. * Inclusion of header files. These are files of declarations that
  435. can be substituted into your program.
  436. * Macro expansion. You can define "macros", which are abbreviations
  437. for arbitrary fragments of C code. The preprocessor will replace
  438. the macros with their definitions throughout the program. Some
  439. macros are automatically defined for you.
  440. * Conditional compilation. You can include or exclude parts of the
  441. program according to various conditions.
  442. * Line control. If you use a program to combine or rearrange source
  443. files into an intermediate file which is then compiled, you can use
  444. line control to inform the compiler where each source line
  445. originally came from.
  446. * Diagnostics. You can detect problems at compile time and issue
  447. errors or warnings.
  448. There are a few more, less useful, features.
  449. Except for expansion of predefined macros, all these operations are
  450. triggered with "preprocessing directives". Preprocessing directives are
  451. lines in your program that start with '#'. Whitespace is allowed before
  452. and after the '#'. The '#' is followed by an identifier, the "directive
  453. name". It specifies the operation to perform. Directives are commonly
  454. referred to as '#NAME' where NAME is the directive name. For example,
  455. '#define' is the directive that defines a macro.
  456. The '#' which begins a directive cannot come from a macro expansion.
  457. Also, the directive name is not macro expanded. Thus, if 'foo' is
  458. defined as a macro expanding to 'define', that does not make '#foo' a
  459. valid preprocessing directive.
  460. The set of valid directive names is fixed. Programs cannot define
  461. new preprocessing directives.
  462. Some directives require arguments; these make up the rest of the
  463. directive line and must be separated from the directive name by
  464. whitespace. For example, '#define' must be followed by a macro name and
  465. the intended expansion of the macro.
  466. A preprocessing directive cannot cover more than one line. The line
  467. may, however, be continued with backslash-newline, or by a block comment
  468. which extends past the end of the line. In either case, when the
  469. directive is processed, the continuations have already been merged with
  470. the first line to make one long line.
  471. 
  472. File: cpp.info, Node: Header Files, Next: Macros, Prev: Overview, Up: Top
  473. 2 Header Files
  474. **************
  475. A header file is a file containing C declarations and macro definitions
  476. (*note Macros::) to be shared between several source files. You request
  477. the use of a header file in your program by "including" it, with the C
  478. preprocessing directive '#include'.
  479. Header files serve two purposes.
  480. * System header files declare the interfaces to parts of the
  481. operating system. You include them in your program to supply the
  482. definitions and declarations you need to invoke system calls and
  483. libraries.
  484. * Your own header files contain declarations for interfaces between
  485. the source files of your program. Each time you have a group of
  486. related declarations and macro definitions all or most of which are
  487. needed in several different source files, it is a good idea to
  488. create a header file for them.
  489. Including a header file produces the same results as copying the
  490. header file into each source file that needs it. Such copying would be
  491. time-consuming and error-prone. With a header file, the related
  492. declarations appear in only one place. If they need to be changed, they
  493. can be changed in one place, and programs that include the header file
  494. will automatically use the new version when next recompiled. The header
  495. file eliminates the labor of finding and changing all the copies as well
  496. as the risk that a failure to find one copy will result in
  497. inconsistencies within a program.
  498. In C, the usual convention is to give header files names that end
  499. with '.h'. It is most portable to use only letters, digits, dashes, and
  500. underscores in header file names, and at most one dot.
  501. * Menu:
  502. * Include Syntax::
  503. * Include Operation::
  504. * Search Path::
  505. * Once-Only Headers::
  506. * Alternatives to Wrapper #ifndef::
  507. * Computed Includes::
  508. * Wrapper Headers::
  509. * System Headers::
  510. 
  511. File: cpp.info, Node: Include Syntax, Next: Include Operation, Up: Header Files
  512. 2.1 Include Syntax
  513. ==================
  514. Both user and system header files are included using the preprocessing
  515. directive '#include'. It has two variants:
  516. '#include <FILE>'
  517. This variant is used for system header files. It searches for a
  518. file named FILE in a standard list of system directories. You can
  519. prepend directories to this list with the '-I' option (*note
  520. Invocation::).
  521. '#include "FILE"'
  522. This variant is used for header files of your own program. It
  523. searches for a file named FILE first in the directory containing
  524. the current file, then in the quote directories and then the same
  525. directories used for '<FILE>'. You can prepend directories to the
  526. list of quote directories with the '-iquote' option.
  527. The argument of '#include', whether delimited with quote marks or
  528. angle brackets, behaves like a string constant in that comments are not
  529. recognized, and macro names are not expanded. Thus, '#include <x/*y>'
  530. specifies inclusion of a system header file named 'x/*y'.
  531. However, if backslashes occur within FILE, they are considered
  532. ordinary text characters, not escape characters. None of the character
  533. escape sequences appropriate to string constants in C are processed.
  534. Thus, '#include "x\n\\y"' specifies a filename containing three
  535. backslashes. (Some systems interpret '\' as a pathname separator. All
  536. of these also interpret '/' the same way. It is most portable to use
  537. only '/'.)
  538. It is an error if there is anything (other than comments) on the line
  539. after the file name.
  540. 
  541. File: cpp.info, Node: Include Operation, Next: Search Path, Prev: Include Syntax, Up: Header Files
  542. 2.2 Include Operation
  543. =====================
  544. The '#include' directive works by directing the C preprocessor to scan
  545. the specified file as input before continuing with the rest of the
  546. current file. The output from the preprocessor contains the output
  547. already generated, followed by the output resulting from the included
  548. file, followed by the output that comes from the text after the
  549. '#include' directive. For example, if you have a header file 'header.h'
  550. as follows,
  551. char *test (void);
  552. and a main program called 'program.c' that uses the header file, like
  553. this,
  554. int x;
  555. #include "header.h"
  556. int
  557. main (void)
  558. {
  559. puts (test ());
  560. }
  561. the compiler will see the same token stream as it would if 'program.c'
  562. read
  563. int x;
  564. char *test (void);
  565. int
  566. main (void)
  567. {
  568. puts (test ());
  569. }
  570. Included files are not limited to declarations and macro definitions;
  571. those are merely the typical uses. Any fragment of a C program can be
  572. included from another file. The include file could even contain the
  573. beginning of a statement that is concluded in the containing file, or
  574. the end of a statement that was started in the including file. However,
  575. an included file must consist of complete tokens. Comments and string
  576. literals which have not been closed by the end of an included file are
  577. invalid. For error recovery, they are considered to end at the end of
  578. the file.
  579. To avoid confusion, it is best if header files contain only complete
  580. syntactic units--function declarations or definitions, type
  581. declarations, etc.
  582. The line following the '#include' directive is always treated as a
  583. separate line by the C preprocessor, even if the included file lacks a
  584. final newline.
  585. 
  586. File: cpp.info, Node: Search Path, Next: Once-Only Headers, Prev: Include Operation, Up: Header Files
  587. 2.3 Search Path
  588. ===============
  589. By default, the preprocessor looks for header files included by the
  590. quote form of the directive '#include "FILE"' first relative to the
  591. directory of the current file, and then in a preconfigured list of
  592. standard system directories. For example, if '/usr/include/sys/stat.h'
  593. contains '#include "types.h"', GCC looks for 'types.h' first in
  594. '/usr/include/sys', then in its usual search path.
  595. For the angle-bracket form '#include <FILE>', the preprocessor's
  596. default behavior is to look only in the standard system directories.
  597. The exact search directory list depends on the target system, how GCC is
  598. configured, and where it is installed. You can find the default search
  599. directory list for your version of CPP by invoking it with the '-v'
  600. option. For example,
  601. cpp -v /dev/null -o /dev/null
  602. There are a number of command-line options you can use to add
  603. additional directories to the search path. The most commonly-used
  604. option is '-IDIR', which causes DIR to be searched after the current
  605. directory (for the quote form of the directive) and ahead of the
  606. standard system directories. You can specify multiple '-I' options on
  607. the command line, in which case the directories are searched in
  608. left-to-right order.
  609. If you need separate control over the search paths for the quote and
  610. angle-bracket forms of the '#include' directive, you can use the
  611. '-iquote' and/or '-isystem' options instead of '-I'. *Note
  612. Invocation::, for a detailed description of these options, as well as
  613. others that are less generally useful.
  614. If you specify other options on the command line, such as '-I', that
  615. affect where the preprocessor searches for header files, the directory
  616. list printed by the '-v' option reflects the actual search path used by
  617. the preprocessor.
  618. Note that you can also prevent the preprocessor from searching any of
  619. the default system header directories with the '-nostdinc' option. This
  620. is useful when you are compiling an operating system kernel or some
  621. other program that does not use the standard C library facilities, or
  622. the standard C library itself.
  623. 
  624. File: cpp.info, Node: Once-Only Headers, Next: Alternatives to Wrapper #ifndef, Prev: Search Path, Up: Header Files
  625. 2.4 Once-Only Headers
  626. =====================
  627. If a header file happens to be included twice, the compiler will process
  628. its contents twice. This is very likely to cause an error, e.g. when
  629. the compiler sees the same structure definition twice. Even if it does
  630. not, it will certainly waste time.
  631. The standard way to prevent this is to enclose the entire real
  632. contents of the file in a conditional, like this:
  633. /* File foo. */
  634. #ifndef FILE_FOO_SEEN
  635. #define FILE_FOO_SEEN
  636. THE ENTIRE FILE
  637. #endif /* !FILE_FOO_SEEN */
  638. This construct is commonly known as a "wrapper #ifndef". When the
  639. header is included again, the conditional will be false, because
  640. 'FILE_FOO_SEEN' is defined. The preprocessor will skip over the entire
  641. contents of the file, and the compiler will not see it twice.
  642. CPP optimizes even further. It remembers when a header file has a
  643. wrapper '#ifndef'. If a subsequent '#include' specifies that header,
  644. and the macro in the '#ifndef' is still defined, it does not bother to
  645. rescan the file at all.
  646. You can put comments outside the wrapper. They will not interfere
  647. with this optimization.
  648. The macro 'FILE_FOO_SEEN' is called the "controlling macro" or "guard
  649. macro". In a user header file, the macro name should not begin with
  650. '_'. In a system header file, it should begin with '__' to avoid
  651. conflicts with user programs. In any kind of header file, the macro
  652. name should contain the name of the file and some additional text, to
  653. avoid conflicts with other header files.
  654. 
  655. File: cpp.info, Node: Alternatives to Wrapper #ifndef, Next: Computed Includes, Prev: Once-Only Headers, Up: Header Files
  656. 2.5 Alternatives to Wrapper #ifndef
  657. ===================================
  658. CPP supports two more ways of indicating that a header file should be
  659. read only once. Neither one is as portable as a wrapper '#ifndef' and
  660. we recommend you do not use them in new programs, with the caveat that
  661. '#import' is standard practice in Objective-C.
  662. CPP supports a variant of '#include' called '#import' which includes
  663. a file, but does so at most once. If you use '#import' instead of
  664. '#include', then you don't need the conditionals inside the header file
  665. to prevent multiple inclusion of the contents. '#import' is standard in
  666. Objective-C, but is considered a deprecated extension in C and C++.
  667. '#import' is not a well designed feature. It requires the users of a
  668. header file to know that it should only be included once. It is much
  669. better for the header file's implementor to write the file so that users
  670. don't need to know this. Using a wrapper '#ifndef' accomplishes this
  671. goal.
  672. In the present implementation, a single use of '#import' will prevent
  673. the file from ever being read again, by either '#import' or '#include'.
  674. You should not rely on this; do not use both '#import' and '#include' to
  675. refer to the same header file.
  676. Another way to prevent a header file from being included more than
  677. once is with the '#pragma once' directive. If '#pragma once' is seen
  678. when scanning a header file, that file will never be read again, no
  679. matter what.
  680. '#pragma once' does not have the problems that '#import' does, but it
  681. is not recognized by all preprocessors, so you cannot rely on it in a
  682. portable program.
  683. 
  684. File: cpp.info, Node: Computed Includes, Next: Wrapper Headers, Prev: Alternatives to Wrapper #ifndef, Up: Header Files
  685. 2.6 Computed Includes
  686. =====================
  687. Sometimes it is necessary to select one of several different header
  688. files to be included into your program. They might specify
  689. configuration parameters to be used on different sorts of operating
  690. systems, for instance. You could do this with a series of conditionals,
  691. #if SYSTEM_1
  692. # include "system_1.h"
  693. #elif SYSTEM_2
  694. # include "system_2.h"
  695. #elif SYSTEM_3
  696. ...
  697. #endif
  698. That rapidly becomes tedious. Instead, the preprocessor offers the
  699. ability to use a macro for the header name. This is called a "computed
  700. include". Instead of writing a header name as the direct argument of
  701. '#include', you simply put a macro name there instead:
  702. #define SYSTEM_H "system_1.h"
  703. ...
  704. #include SYSTEM_H
  705. 'SYSTEM_H' will be expanded, and the preprocessor will look for
  706. 'system_1.h' as if the '#include' had been written that way originally.
  707. 'SYSTEM_H' could be defined by your Makefile with a '-D' option.
  708. You must be careful when you define the macro. '#define' saves
  709. tokens, not text. The preprocessor has no way of knowing that the macro
  710. will be used as the argument of '#include', so it generates ordinary
  711. tokens, not a header name. This is unlikely to cause problems if you
  712. use double-quote includes, which are close enough to string constants.
  713. If you use angle brackets, however, you may have trouble.
  714. The syntax of a computed include is actually a bit more general than
  715. the above. If the first non-whitespace character after '#include' is
  716. not '"' or '<', then the entire line is macro-expanded like running text
  717. would be.
  718. If the line expands to a single string constant, the contents of that
  719. string constant are the file to be included. CPP does not re-examine
  720. the string for embedded quotes, but neither does it process backslash
  721. escapes in the string. Therefore
  722. #define HEADER "a\"b"
  723. #include HEADER
  724. looks for a file named 'a\"b'. CPP searches for the file according to
  725. the rules for double-quoted includes.
  726. If the line expands to a token stream beginning with a '<' token and
  727. including a '>' token, then the tokens between the '<' and the first '>'
  728. are combined to form the filename to be included. Any whitespace
  729. between tokens is reduced to a single space; then any space after the
  730. initial '<' is retained, but a trailing space before the closing '>' is
  731. ignored. CPP searches for the file according to the rules for
  732. angle-bracket includes.
  733. In either case, if there are any tokens on the line after the file
  734. name, an error occurs and the directive is not processed. It is also an
  735. error if the result of expansion does not match either of the two
  736. expected forms.
  737. These rules are implementation-defined behavior according to the C
  738. standard. To minimize the risk of different compilers interpreting your
  739. computed includes differently, we recommend you use only a single
  740. object-like macro which expands to a string constant. This will also
  741. minimize confusion for people reading your program.
  742. 
  743. File: cpp.info, Node: Wrapper Headers, Next: System Headers, Prev: Computed Includes, Up: Header Files
  744. 2.7 Wrapper Headers
  745. ===================
  746. Sometimes it is necessary to adjust the contents of a system-provided
  747. header file without editing it directly. GCC's 'fixincludes' operation
  748. does this, for example. One way to do that would be to create a new
  749. header file with the same name and insert it in the search path before
  750. the original header. That works fine as long as you're willing to
  751. replace the old header entirely. But what if you want to refer to the
  752. old header from the new one?
  753. You cannot simply include the old header with '#include'. That will
  754. start from the beginning, and find your new header again. If your
  755. header is not protected from multiple inclusion (*note Once-Only
  756. Headers::), it will recurse infinitely and cause a fatal error.
  757. You could include the old header with an absolute pathname:
  758. #include "/usr/include/old-header.h"
  759. This works, but is not clean; should the system headers ever move, you
  760. would have to edit the new headers to match.
  761. There is no way to solve this problem within the C standard, but you
  762. can use the GNU extension '#include_next'. It means, "Include the
  763. _next_ file with this name". This directive works like '#include'
  764. except in searching for the specified file: it starts searching the list
  765. of header file directories _after_ the directory in which the current
  766. file was found.
  767. Suppose you specify '-I /usr/local/include', and the list of
  768. directories to search also includes '/usr/include'; and suppose both
  769. directories contain 'signal.h'. Ordinary '#include <signal.h>' finds
  770. the file under '/usr/local/include'. If that file contains
  771. '#include_next <signal.h>', it starts searching after that directory,
  772. and finds the file in '/usr/include'.
  773. '#include_next' does not distinguish between '<FILE>' and '"FILE"'
  774. inclusion, nor does it check that the file you specify has the same name
  775. as the current file. It simply looks for the file named, starting with
  776. the directory in the search path after the one where the current file
  777. was found.
  778. The use of '#include_next' can lead to great confusion. We recommend
  779. it be used only when there is no other alternative. In particular, it
  780. should not be used in the headers belonging to a specific program; it
  781. should be used only to make global corrections along the lines of
  782. 'fixincludes'.
  783. 
  784. File: cpp.info, Node: System Headers, Prev: Wrapper Headers, Up: Header Files
  785. 2.8 System Headers
  786. ==================
  787. The header files declaring interfaces to the operating system and
  788. runtime libraries often cannot be written in strictly conforming C.
  789. Therefore, GCC gives code found in "system headers" special treatment.
  790. All warnings, other than those generated by '#warning' (*note
  791. Diagnostics::), are suppressed while GCC is processing a system header.
  792. Macros defined in a system header are immune to a few warnings wherever
  793. they are expanded. This immunity is granted on an ad-hoc basis, when we
  794. find that a warning generates lots of false positives because of code in
  795. macros defined in system headers.
  796. Normally, only the headers found in specific directories are
  797. considered system headers. These directories are determined when GCC is
  798. compiled. There are, however, two ways to make normal headers into
  799. system headers:
  800. * Header files found in directories added to the search path with the
  801. '-isystem' and '-idirafter' command-line options are treated as
  802. system headers for the purposes of diagnostics.
  803. * There is also a directive, '#pragma GCC system_header', which tells
  804. GCC to consider the rest of the current include file a system
  805. header, no matter where it was found. Code that comes before the
  806. '#pragma' in the file is not affected. '#pragma GCC system_header'
  807. has no effect in the primary source file.
  808. 
  809. File: cpp.info, Node: Macros, Next: Conditionals, Prev: Header Files, Up: Top
  810. 3 Macros
  811. ********
  812. A "macro" is a fragment of code which has been given a name. Whenever
  813. the name is used, it is replaced by the contents of the macro. There
  814. are two kinds of macros. They differ mostly in what they look like when
  815. they are used. "Object-like" macros resemble data objects when used,
  816. "function-like" macros resemble function calls.
  817. You may define any valid identifier as a macro, even if it is a C
  818. keyword. The preprocessor does not know anything about keywords. This
  819. can be useful if you wish to hide a keyword such as 'const' from an
  820. older compiler that does not understand it. However, the preprocessor
  821. operator 'defined' (*note Defined::) can never be defined as a macro,
  822. and C++'s named operators (*note C++ Named Operators::) cannot be macros
  823. when you are compiling C++.
  824. * Menu:
  825. * Object-like Macros::
  826. * Function-like Macros::
  827. * Macro Arguments::
  828. * Stringizing::
  829. * Concatenation::
  830. * Variadic Macros::
  831. * Predefined Macros::
  832. * Undefining and Redefining Macros::
  833. * Directives Within Macro Arguments::
  834. * Macro Pitfalls::
  835. 
  836. File: cpp.info, Node: Object-like Macros, Next: Function-like Macros, Up: Macros
  837. 3.1 Object-like Macros
  838. ======================
  839. An "object-like macro" is a simple identifier which will be replaced by
  840. a code fragment. It is called object-like because it looks like a data
  841. object in code that uses it. They are most commonly used to give
  842. symbolic names to numeric constants.
  843. You create macros with the '#define' directive. '#define' is
  844. followed by the name of the macro and then the token sequence it should
  845. be an abbreviation for, which is variously referred to as the macro's
  846. "body", "expansion" or "replacement list". For example,
  847. #define BUFFER_SIZE 1024
  848. defines a macro named 'BUFFER_SIZE' as an abbreviation for the token
  849. '1024'. If somewhere after this '#define' directive there comes a C
  850. statement of the form
  851. foo = (char *) malloc (BUFFER_SIZE);
  852. then the C preprocessor will recognize and "expand" the macro
  853. 'BUFFER_SIZE'. The C compiler will see the same tokens as it would if
  854. you had written
  855. foo = (char *) malloc (1024);
  856. By convention, macro names are written in uppercase. Programs are
  857. easier to read when it is possible to tell at a glance which names are
  858. macros.
  859. The macro's body ends at the end of the '#define' line. You may
  860. continue the definition onto multiple lines, if necessary, using
  861. backslash-newline. When the macro is expanded, however, it will all
  862. come out on one line. For example,
  863. #define NUMBERS 1, \
  864. 2, \
  865. 3
  866. int x[] = { NUMBERS };
  867. ==> int x[] = { 1, 2, 3 };
  868. The most common visible consequence of this is surprising line numbers
  869. in error messages.
  870. There is no restriction on what can go in a macro body provided it
  871. decomposes into valid preprocessing tokens. Parentheses need not
  872. balance, and the body need not resemble valid C code. (If it does not,
  873. you may get error messages from the C compiler when you use the macro.)
  874. The C preprocessor scans your program sequentially. Macro
  875. definitions take effect at the place you write them. Therefore, the
  876. following input to the C preprocessor
  877. foo = X;
  878. #define X 4
  879. bar = X;
  880. produces
  881. foo = X;
  882. bar = 4;
  883. When the preprocessor expands a macro name, the macro's expansion
  884. replaces the macro invocation, then the expansion is examined for more
  885. macros to expand. For example,
  886. #define TABLESIZE BUFSIZE
  887. #define BUFSIZE 1024
  888. TABLESIZE
  889. ==> BUFSIZE
  890. ==> 1024
  891. 'TABLESIZE' is expanded first to produce 'BUFSIZE', then that macro is
  892. expanded to produce the final result, '1024'.
  893. Notice that 'BUFSIZE' was not defined when 'TABLESIZE' was defined.
  894. The '#define' for 'TABLESIZE' uses exactly the expansion you specify--in
  895. this case, 'BUFSIZE'--and does not check to see whether it too contains
  896. macro names. Only when you _use_ 'TABLESIZE' is the result of its
  897. expansion scanned for more macro names.
  898. This makes a difference if you change the definition of 'BUFSIZE' at
  899. some point in the source file. 'TABLESIZE', defined as shown, will
  900. always expand using the definition of 'BUFSIZE' that is currently in
  901. effect:
  902. #define BUFSIZE 1020
  903. #define TABLESIZE BUFSIZE
  904. #undef BUFSIZE
  905. #define BUFSIZE 37
  906. Now 'TABLESIZE' expands (in two stages) to '37'.
  907. If the expansion of a macro contains its own name, either directly or
  908. via intermediate macros, it is not expanded again when the expansion is
  909. examined for more macros. This prevents infinite recursion. *Note
  910. Self-Referential Macros::, for the precise details.
  911. 
  912. File: cpp.info, Node: Function-like Macros, Next: Macro Arguments, Prev: Object-like Macros, Up: Macros
  913. 3.2 Function-like Macros
  914. ========================
  915. You can also define macros whose use looks like a function call. These
  916. are called "function-like macros". To define a function-like macro, you
  917. use the same '#define' directive, but you put a pair of parentheses
  918. immediately after the macro name. For example,
  919. #define lang_init() c_init()
  920. lang_init()
  921. ==> c_init()
  922. A function-like macro is only expanded if its name appears with a
  923. pair of parentheses after it. If you write just the name, it is left
  924. alone. This can be useful when you have a function and a macro of the
  925. same name, and you wish to use the function sometimes.
  926. extern void foo(void);
  927. #define foo() /* optimized inline version */
  928. ...
  929. foo();
  930. funcptr = foo;
  931. Here the call to 'foo()' will use the macro, but the function pointer
  932. will get the address of the real function. If the macro were to be
  933. expanded, it would cause a syntax error.
  934. If you put spaces between the macro name and the parentheses in the
  935. macro definition, that does not define a function-like macro, it defines
  936. an object-like macro whose expansion happens to begin with a pair of
  937. parentheses.
  938. #define lang_init () c_init()
  939. lang_init()
  940. ==> () c_init()()
  941. The first two pairs of parentheses in this expansion come from the
  942. macro. The third is the pair that was originally after the macro
  943. invocation. Since 'lang_init' is an object-like macro, it does not
  944. consume those parentheses.
  945. 
  946. File: cpp.info, Node: Macro Arguments, Next: Stringizing, Prev: Function-like Macros, Up: Macros
  947. 3.3 Macro Arguments
  948. ===================
  949. Function-like macros can take "arguments", just like true functions. To
  950. define a macro that uses arguments, you insert "parameters" between the
  951. pair of parentheses in the macro definition that make the macro
  952. function-like. The parameters must be valid C identifiers, separated by
  953. commas and optionally whitespace.
  954. To invoke a macro that takes arguments, you write the name of the
  955. macro followed by a list of "actual arguments" in parentheses, separated
  956. by commas. The invocation of the macro need not be restricted to a
  957. single logical line--it can cross as many lines in the source file as
  958. you wish. The number of arguments you give must match the number of
  959. parameters in the macro definition. When the macro is expanded, each
  960. use of a parameter in its body is replaced by the tokens of the
  961. corresponding argument. (You need not use all of the parameters in the
  962. macro body.)
  963. As an example, here is a macro that computes the minimum of two
  964. numeric values, as it is defined in many C programs, and some uses.
  965. #define min(X, Y) ((X) < (Y) ? (X) : (Y))
  966. x = min(a, b); ==> x = ((a) < (b) ? (a) : (b));
  967. y = min(1, 2); ==> y = ((1) < (2) ? (1) : (2));
  968. z = min(a + 28, *p); ==> z = ((a + 28) < (*p) ? (a + 28) : (*p));
  969. (In this small example you can already see several of the dangers of
  970. macro arguments. *Note Macro Pitfalls::, for detailed explanations.)
  971. Leading and trailing whitespace in each argument is dropped, and all
  972. whitespace between the tokens of an argument is reduced to a single
  973. space. Parentheses within each argument must balance; a comma within
  974. such parentheses does not end the argument. However, there is no
  975. requirement for square brackets or braces to balance, and they do not
  976. prevent a comma from separating arguments. Thus,
  977. macro (array[x = y, x + 1])
  978. passes two arguments to 'macro': 'array[x = y' and 'x + 1]'. If you
  979. want to supply 'array[x = y, x + 1]' as an argument, you can write it as
  980. 'array[(x = y, x + 1)]', which is equivalent C code.
  981. All arguments to a macro are completely macro-expanded before they
  982. are substituted into the macro body. After substitution, the complete
  983. text is scanned again for macros to expand, including the arguments.
  984. This rule may seem strange, but it is carefully designed so you need not
  985. worry about whether any function call is actually a macro invocation.
  986. You can run into trouble if you try to be too clever, though. *Note
  987. Argument Prescan::, for detailed discussion.
  988. For example, 'min (min (a, b), c)' is first expanded to
  989. min (((a) < (b) ? (a) : (b)), (c))
  990. and then to
  991. ((((a) < (b) ? (a) : (b))) < (c)
  992. ? (((a) < (b) ? (a) : (b)))
  993. : (c))
  994. (Line breaks shown here for clarity would not actually be generated.)
  995. You can leave macro arguments empty; this is not an error to the
  996. preprocessor (but many macros will then expand to invalid code). You
  997. cannot leave out arguments entirely; if a macro takes two arguments,
  998. there must be exactly one comma at the top level of its argument list.
  999. Here are some silly examples using 'min':
  1000. min(, b) ==> (( ) < (b) ? ( ) : (b))
  1001. min(a, ) ==> ((a ) < ( ) ? (a ) : ( ))
  1002. min(,) ==> (( ) < ( ) ? ( ) : ( ))
  1003. min((,),) ==> (((,)) < ( ) ? ((,)) : ( ))
  1004. min() error-> macro "min" requires 2 arguments, but only 1 given
  1005. min(,,) error-> macro "min" passed 3 arguments, but takes just 2
  1006. Whitespace is not a preprocessing token, so if a macro 'foo' takes
  1007. one argument, 'foo ()' and 'foo ( )' both supply it an empty argument.
  1008. Previous GNU preprocessor implementations and documentation were
  1009. incorrect on this point, insisting that a function-like macro that takes
  1010. a single argument be passed a space if an empty argument was required.
  1011. Macro parameters appearing inside string literals are not replaced by
  1012. their corresponding actual arguments.
  1013. #define foo(x) x, "x"
  1014. foo(bar) ==> bar, "x"
  1015. 
  1016. File: cpp.info, Node: Stringizing, Next: Concatenation, Prev: Macro Arguments, Up: Macros
  1017. 3.4 Stringizing
  1018. ===============
  1019. Sometimes you may want to convert a macro argument into a string
  1020. constant. Parameters are not replaced inside string constants, but you
  1021. can use the '#' preprocessing operator instead. When a macro parameter
  1022. is used with a leading '#', the preprocessor replaces it with the
  1023. literal text of the actual argument, converted to a string constant.
  1024. Unlike normal parameter replacement, the argument is not macro-expanded
  1025. first. This is called "stringizing".
  1026. There is no way to combine an argument with surrounding text and
  1027. stringize it all together. Instead, you can write a series of adjacent
  1028. string constants and stringized arguments. The preprocessor replaces
  1029. the stringized arguments with string constants. The C compiler then
  1030. combines all the adjacent string constants into one long string.
  1031. Here is an example of a macro definition that uses stringizing:
  1032. #define WARN_IF(EXP) \
  1033. do { if (EXP) \
  1034. fprintf (stderr, "Warning: " #EXP "\n"); } \
  1035. while (0)
  1036. WARN_IF (x == 0);
  1037. ==> do { if (x == 0)
  1038. fprintf (stderr, "Warning: " "x == 0" "\n"); } while (0);
  1039. The argument for 'EXP' is substituted once, as-is, into the 'if'
  1040. statement, and once, stringized, into the argument to 'fprintf'. If 'x'
  1041. were a macro, it would be expanded in the 'if' statement, but not in the
  1042. string.
  1043. The 'do' and 'while (0)' are a kludge to make it possible to write
  1044. 'WARN_IF (ARG);', which the resemblance of 'WARN_IF' to a function would
  1045. make C programmers want to do; see *note Swallowing the Semicolon::.
  1046. Stringizing in C involves more than putting double-quote characters
  1047. around the fragment. The preprocessor backslash-escapes the quotes
  1048. surrounding embedded string constants, and all backslashes within string
  1049. and character constants, in order to get a valid C string constant with
  1050. the proper contents. Thus, stringizing 'p = "foo\n";' results in
  1051. "p = \"foo\\n\";". However, backslashes that are not inside string or
  1052. character constants are not duplicated: '\n' by itself stringizes to
  1053. "\n".
  1054. All leading and trailing whitespace in text being stringized is
  1055. ignored. Any sequence of whitespace in the middle of the text is
  1056. converted to a single space in the stringized result. Comments are
  1057. replaced by whitespace long before stringizing happens, so they never
  1058. appear in stringized text.
  1059. There is no way to convert a macro argument into a character
  1060. constant.
  1061. If you want to stringize the result of expansion of a macro argument,
  1062. you have to use two levels of macros.
  1063. #define xstr(s) str(s)
  1064. #define str(s) #s
  1065. #define foo 4
  1066. str (foo)
  1067. ==> "foo"
  1068. xstr (foo)
  1069. ==> xstr (4)
  1070. ==> str (4)
  1071. ==> "4"
  1072. 's' is stringized when it is used in 'str', so it is not
  1073. macro-expanded first. But 's' is an ordinary argument to 'xstr', so it
  1074. is completely macro-expanded before 'xstr' itself is expanded (*note
  1075. Argument Prescan::). Therefore, by the time 'str' gets to its argument,
  1076. it has already been macro-expanded.
  1077. 
  1078. File: cpp.info, Node: Concatenation, Next: Variadic Macros, Prev: Stringizing, Up: Macros
  1079. 3.5 Concatenation
  1080. =================
  1081. It is often useful to merge two tokens into one while expanding macros.
  1082. This is called "token pasting" or "token concatenation". The '##'
  1083. preprocessing operator performs token pasting. When a macro is
  1084. expanded, the two tokens on either side of each '##' operator are
  1085. combined into a single token, which then replaces the '##' and the two
  1086. original tokens in the macro expansion. Usually both will be
  1087. identifiers, or one will be an identifier and the other a preprocessing
  1088. number. When pasted, they make a longer identifier. This isn't the
  1089. only valid case. It is also possible to concatenate two numbers (or a
  1090. number and a name, such as '1.5' and 'e3') into a number. Also,
  1091. multi-character operators such as '+=' can be formed by token pasting.
  1092. However, two tokens that don't together form a valid token cannot be
  1093. pasted together. For example, you cannot concatenate 'x' with '+' in
  1094. either order. If you try, the preprocessor issues a warning and emits
  1095. the two tokens. Whether it puts white space between the tokens is
  1096. undefined. It is common to find unnecessary uses of '##' in complex
  1097. macros. If you get this warning, it is likely that you can simply
  1098. remove the '##'.
  1099. Both the tokens combined by '##' could come from the macro body, but
  1100. you could just as well write them as one token in the first place.
  1101. Token pasting is most useful when one or both of the tokens comes from a
  1102. macro argument. If either of the tokens next to an '##' is a parameter
  1103. name, it is replaced by its actual argument before '##' executes. As
  1104. with stringizing, the actual argument is not macro-expanded first. If
  1105. the argument is empty, that '##' has no effect.
  1106. Keep in mind that the C preprocessor converts comments to whitespace
  1107. before macros are even considered. Therefore, you cannot create a
  1108. comment by concatenating '/' and '*'. You can put as much whitespace
  1109. between '##' and its operands as you like, including comments, and you
  1110. can put comments in arguments that will be concatenated. However, it is
  1111. an error if '##' appears at either end of a macro body.
  1112. Consider a C program that interprets named commands. There probably
  1113. needs to be a table of commands, perhaps an array of structures declared
  1114. as follows:
  1115. struct command
  1116. {
  1117. char *name;
  1118. void (*function) (void);
  1119. };
  1120. struct command commands[] =
  1121. {
  1122. { "quit", quit_command },
  1123. { "help", help_command },
  1124. ...
  1125. };
  1126. It would be cleaner not to have to give each command name twice, once
  1127. in the string constant and once in the function name. A macro which
  1128. takes the name of a command as an argument can make this unnecessary.
  1129. The string constant can be created with stringizing, and the function
  1130. name by concatenating the argument with '_command'. Here is how it is
  1131. done:
  1132. #define COMMAND(NAME) { #NAME, NAME ## _command }
  1133. struct command commands[] =
  1134. {
  1135. COMMAND (quit),
  1136. COMMAND (help),
  1137. ...
  1138. };
  1139. 
  1140. File: cpp.info, Node: Variadic Macros, Next: Predefined Macros, Prev: Concatenation, Up: Macros
  1141. 3.6 Variadic Macros
  1142. ===================
  1143. A macro can be declared to accept a variable number of arguments much as
  1144. a function can. The syntax for defining the macro is similar to that of
  1145. a function. Here is an example:
  1146. #define eprintf(...) fprintf (stderr, __VA_ARGS__)
  1147. This kind of macro is called "variadic". When the macro is invoked,
  1148. all the tokens in its argument list after the last named argument (this
  1149. macro has none), including any commas, become the "variable argument".
  1150. This sequence of tokens replaces the identifier '__VA_ARGS__' in the
  1151. macro body wherever it appears. Thus, we have this expansion:
  1152. eprintf ("%s:%d: ", input_file, lineno)
  1153. ==> fprintf (stderr, "%s:%d: ", input_file, lineno)
  1154. The variable argument is completely macro-expanded before it is
  1155. inserted into the macro expansion, just like an ordinary argument. You
  1156. may use the '#' and '##' operators to stringize the variable argument or
  1157. to paste its leading or trailing token with another token. (But see
  1158. below for an important special case for '##'.)
  1159. If your macro is complicated, you may want a more descriptive name
  1160. for the variable argument than '__VA_ARGS__'. CPP permits this, as an
  1161. extension. You may write an argument name immediately before the '...';
  1162. that name is used for the variable argument. The 'eprintf' macro above
  1163. could be written
  1164. #define eprintf(args...) fprintf (stderr, args)
  1165. using this extension. You cannot use '__VA_ARGS__' and this extension
  1166. in the same macro.
  1167. You can have named arguments as well as variable arguments in a
  1168. variadic macro. We could define 'eprintf' like this, instead:
  1169. #define eprintf(format, ...) fprintf (stderr, format, __VA_ARGS__)
  1170. This formulation looks more descriptive, but unfortunately it is less
  1171. flexible: you must now supply at least one argument after the format
  1172. string. In standard C, you cannot omit the comma separating the named
  1173. argument from the variable arguments. Furthermore, if you leave the
  1174. variable argument empty, you will get a syntax error, because there will
  1175. be an extra comma after the format string.
  1176. eprintf("success!\n", );
  1177. ==> fprintf(stderr, "success!\n", );
  1178. GNU CPP has a pair of extensions which deal with this problem.
  1179. First, you are allowed to leave the variable argument out entirely:
  1180. eprintf ("success!\n")
  1181. ==> fprintf(stderr, "success!\n", );
  1182. Second, the '##' token paste operator has a special meaning when placed
  1183. between a comma and a variable argument. If you write
  1184. #define eprintf(format, ...) fprintf (stderr, format, ##__VA_ARGS__)
  1185. and the variable argument is left out when the 'eprintf' macro is used,
  1186. then the comma before the '##' will be deleted. This does _not_ happen
  1187. if you pass an empty argument, nor does it happen if the token preceding
  1188. '##' is anything other than a comma.
  1189. eprintf ("success!\n")
  1190. ==> fprintf(stderr, "success!\n");
  1191. The above explanation is ambiguous about the case where the only macro
  1192. parameter is a variable arguments parameter, as it is meaningless to try
  1193. to distinguish whether no argument at all is an empty argument or a
  1194. missing argument. CPP retains the comma when conforming to a specific C
  1195. standard. Otherwise the comma is dropped as an extension to the
  1196. standard.
  1197. The C standard mandates that the only place the identifier
  1198. '__VA_ARGS__' can appear is in the replacement list of a variadic macro.
  1199. It may not be used as a macro name, macro argument name, or within a
  1200. different type of macro. It may also be forbidden in open text; the
  1201. standard is ambiguous. We recommend you avoid using it except for its
  1202. defined purpose.
  1203. Variadic macros became a standard part of the C language with C99.
  1204. GNU CPP previously supported them with a named variable argument
  1205. ('args...', not '...' and '__VA_ARGS__'), which is still supported for
  1206. backward compatibility.
  1207. 
  1208. File: cpp.info, Node: Predefined Macros, Next: Undefining and Redefining Macros, Prev: Variadic Macros, Up: Macros
  1209. 3.7 Predefined Macros
  1210. =====================
  1211. Several object-like macros are predefined; you use them without
  1212. supplying their definitions. They fall into three classes: standard,
  1213. common, and system-specific.
  1214. In C++, there is a fourth category, the named operators. They act
  1215. like predefined macros, but you cannot undefine them.
  1216. * Menu:
  1217. * Standard Predefined Macros::
  1218. * Common Predefined Macros::
  1219. * System-specific Predefined Macros::
  1220. * C++ Named Operators::
  1221. 
  1222. File: cpp.info, Node: Standard Predefined Macros, Next: Common Predefined Macros, Up: Predefined Macros
  1223. 3.7.1 Standard Predefined Macros
  1224. --------------------------------
  1225. The standard predefined macros are specified by the relevant language
  1226. standards, so they are available with all compilers that implement those
  1227. standards. Older compilers may not provide all of them. Their names
  1228. all start with double underscores.
  1229. '__FILE__'
  1230. This macro expands to the name of the current input file, in the
  1231. form of a C string constant. This is the path by which the
  1232. preprocessor opened the file, not the short name specified in
  1233. '#include' or as the input file name argument. For example,
  1234. '"/usr/local/include/myheader.h"' is a possible expansion of this
  1235. macro.
  1236. '__LINE__'
  1237. This macro expands to the current input line number, in the form of
  1238. a decimal integer constant. While we call it a predefined macro,
  1239. it's a pretty strange macro, since its "definition" changes with
  1240. each new line of source code.
  1241. '__FILE__' and '__LINE__' are useful in generating an error message
  1242. to report an inconsistency detected by the program; the message can
  1243. state the source line at which the inconsistency was detected. For
  1244. example,
  1245. fprintf (stderr, "Internal error: "
  1246. "negative string length "
  1247. "%d at %s, line %d.",
  1248. length, __FILE__, __LINE__);
  1249. An '#include' directive changes the expansions of '__FILE__' and
  1250. '__LINE__' to correspond to the included file. At the end of that file,
  1251. when processing resumes on the input file that contained the '#include'
  1252. directive, the expansions of '__FILE__' and '__LINE__' revert to the
  1253. values they had before the '#include' (but '__LINE__' is then
  1254. incremented by one as processing moves to the line after the
  1255. '#include').
  1256. A '#line' directive changes '__LINE__', and may change '__FILE__' as
  1257. well. *Note Line Control::.
  1258. C99 introduced '__func__', and GCC has provided '__FUNCTION__' for a
  1259. long time. Both of these are strings containing the name of the current
  1260. function (there are slight semantic differences; see the GCC manual).
  1261. Neither of them is a macro; the preprocessor does not know the name of
  1262. the current function. They tend to be useful in conjunction with
  1263. '__FILE__' and '__LINE__', though.
  1264. '__DATE__'
  1265. This macro expands to a string constant that describes the date on
  1266. which the preprocessor is being run. The string constant contains
  1267. eleven characters and looks like '"Feb 12 1996"'. If the day of
  1268. the month is less than 10, it is padded with a space on the left.
  1269. If GCC cannot determine the current date, it will emit a warning
  1270. message (once per compilation) and '__DATE__' will expand to
  1271. '"??? ?? ????"'.
  1272. '__TIME__'
  1273. This macro expands to a string constant that describes the time at
  1274. which the preprocessor is being run. The string constant contains
  1275. eight characters and looks like '"23:59:01"'.
  1276. If GCC cannot determine the current time, it will emit a warning
  1277. message (once per compilation) and '__TIME__' will expand to
  1278. '"??:??:??"'.
  1279. '__STDC__'
  1280. In normal operation, this macro expands to the constant 1, to
  1281. signify that this compiler conforms to ISO Standard C. If GNU CPP
  1282. is used with a compiler other than GCC, this is not necessarily
  1283. true; however, the preprocessor always conforms to the standard
  1284. unless the '-traditional-cpp' option is used.
  1285. This macro is not defined if the '-traditional-cpp' option is used.
  1286. On some hosts, the system compiler uses a different convention,
  1287. where '__STDC__' is normally 0, but is 1 if the user specifies
  1288. strict conformance to the C Standard. CPP follows the host
  1289. convention when processing system header files, but when processing
  1290. user files '__STDC__' is always 1. This has been reported to cause
  1291. problems; for instance, some versions of Solaris provide X Windows
  1292. headers that expect '__STDC__' to be either undefined or 1. *Note
  1293. Invocation::.
  1294. '__STDC_VERSION__'
  1295. This macro expands to the C Standard's version number, a long
  1296. integer constant of the form 'YYYYMML' where YYYY and MM are the
  1297. year and month of the Standard version. This signifies which
  1298. version of the C Standard the compiler conforms to. Like
  1299. '__STDC__', this is not necessarily accurate for the entire
  1300. implementation, unless GNU CPP is being used with GCC.
  1301. The value '199409L' signifies the 1989 C standard as amended in
  1302. 1994, which is the current default; the value '199901L' signifies
  1303. the 1999 revision of the C standard. Support for the 1999 revision
  1304. is not yet complete.
  1305. This macro is not defined if the '-traditional-cpp' option is used,
  1306. nor when compiling C++ or Objective-C.
  1307. '__STDC_HOSTED__'
  1308. This macro is defined, with value 1, if the compiler's target is a
  1309. "hosted environment". A hosted environment has the complete
  1310. facilities of the standard C library available.
  1311. '__cplusplus'
  1312. This macro is defined when the C++ compiler is in use. You can use
  1313. '__cplusplus' to test whether a header is compiled by a C compiler
  1314. or a C++ compiler. This macro is similar to '__STDC_VERSION__', in
  1315. that it expands to a version number. Depending on the language
  1316. standard selected, the value of the macro is '199711L' for the 1998
  1317. C++ standard, '201103L' for the 2011 C++ standard, '201402L' for
  1318. the 2014 C++ standard, or an unspecified value strictly larger than
  1319. '201402L' for the experimental languages enabled by '-std=c++1z'
  1320. and '-std=gnu++1z'.
  1321. '__OBJC__'
  1322. This macro is defined, with value 1, when the Objective-C compiler
  1323. is in use. You can use '__OBJC__' to test whether a header is
  1324. compiled by a C compiler or an Objective-C compiler.
  1325. '__ASSEMBLER__'
  1326. This macro is defined with value 1 when preprocessing assembly
  1327. language.
  1328. 
  1329. File: cpp.info, Node: Common Predefined Macros, Next: System-specific Predefined Macros, Prev: Standard Predefined Macros, Up: Predefined Macros
  1330. 3.7.2 Common Predefined Macros
  1331. ------------------------------
  1332. The common predefined macros are GNU C extensions. They are available
  1333. with the same meanings regardless of the machine or operating system on
  1334. which you are using GNU C or GNU Fortran. Their names all start with
  1335. double underscores.
  1336. '__COUNTER__'
  1337. This macro expands to sequential integral values starting from 0.
  1338. In conjunction with the '##' operator, this provides a convenient
  1339. means to generate unique identifiers. Care must be taken to ensure
  1340. that '__COUNTER__' is not expanded prior to inclusion of
  1341. precompiled headers which use it. Otherwise, the precompiled
  1342. headers will not be used.
  1343. '__GFORTRAN__'
  1344. The GNU Fortran compiler defines this.
  1345. '__GNUC__'
  1346. '__GNUC_MINOR__'
  1347. '__GNUC_PATCHLEVEL__'
  1348. These macros are defined by all GNU compilers that use the C
  1349. preprocessor: C, C++, Objective-C and Fortran. Their values are
  1350. the major version, minor version, and patch level of the compiler,
  1351. as integer constants. For example, GCC version X.Y.Z defines
  1352. '__GNUC__' to X, '__GNUC_MINOR__' to Y, and '__GNUC_PATCHLEVEL__'
  1353. to Z. These macros are also defined if you invoke the preprocessor
  1354. directly.
  1355. If all you need to know is whether or not your program is being
  1356. compiled by GCC, or a non-GCC compiler that claims to accept the
  1357. GNU C dialects, you can simply test '__GNUC__'. If you need to
  1358. write code which depends on a specific version, you must be more
  1359. careful. Each time the minor version is increased, the patch level
  1360. is reset to zero; each time the major version is increased, the
  1361. minor version and patch level are reset. If you wish to use the
  1362. predefined macros directly in the conditional, you will need to
  1363. write it like this:
  1364. /* Test for GCC > 3.2.0 */
  1365. #if __GNUC__ > 3 || \
  1366. (__GNUC__ == 3 && (__GNUC_MINOR__ > 2 || \
  1367. (__GNUC_MINOR__ == 2 && \
  1368. __GNUC_PATCHLEVEL__ > 0))
  1369. Another approach is to use the predefined macros to calculate a
  1370. single number, then compare that against a threshold:
  1371. #define GCC_VERSION (__GNUC__ * 10000 \
  1372. + __GNUC_MINOR__ * 100 \
  1373. + __GNUC_PATCHLEVEL__)
  1374. ...
  1375. /* Test for GCC > 3.2.0 */
  1376. #if GCC_VERSION > 30200
  1377. Many people find this form easier to understand.
  1378. '__GNUG__'
  1379. The GNU C++ compiler defines this. Testing it is equivalent to
  1380. testing '(__GNUC__ && __cplusplus)'.
  1381. '__STRICT_ANSI__'
  1382. GCC defines this macro if and only if the '-ansi' switch, or a
  1383. '-std' switch specifying strict conformance to some version of ISO
  1384. C or ISO C++, was specified when GCC was invoked. It is defined to
  1385. '1'. This macro exists primarily to direct GNU libc's header files
  1386. to use only definitions found in standard C.
  1387. '__BASE_FILE__'
  1388. This macro expands to the name of the main input file, in the form
  1389. of a C string constant. This is the source file that was specified
  1390. on the command line of the preprocessor or C compiler.
  1391. '__INCLUDE_LEVEL__'
  1392. This macro expands to a decimal integer constant that represents
  1393. the depth of nesting in include files. The value of this macro is
  1394. incremented on every '#include' directive and decremented at the
  1395. end of every included file. It starts out at 0, its value within
  1396. the base file specified on the command line.
  1397. '__ELF__'
  1398. This macro is defined if the target uses the ELF object format.
  1399. '__VERSION__'
  1400. This macro expands to a string constant which describes the version
  1401. of the compiler in use. You should not rely on its contents having
  1402. any particular form, but it can be counted on to contain at least
  1403. the release number.
  1404. '__OPTIMIZE__'
  1405. '__OPTIMIZE_SIZE__'
  1406. '__NO_INLINE__'
  1407. These macros describe the compilation mode. '__OPTIMIZE__' is
  1408. defined in all optimizing compilations. '__OPTIMIZE_SIZE__' is
  1409. defined if the compiler is optimizing for size, not speed.
  1410. '__NO_INLINE__' is defined if no functions will be inlined into
  1411. their callers (when not optimizing, or when inlining has been
  1412. specifically disabled by '-fno-inline').
  1413. These macros cause certain GNU header files to provide optimized
  1414. definitions, using macros or inline functions, of system library
  1415. functions. You should not use these macros in any way unless you
  1416. make sure that programs will execute with the same effect whether
  1417. or not they are defined. If they are defined, their value is 1.
  1418. '__GNUC_GNU_INLINE__'
  1419. GCC defines this macro if functions declared 'inline' will be
  1420. handled in GCC's traditional gnu90 mode. Object files will contain
  1421. externally visible definitions of all functions declared 'inline'
  1422. without 'extern' or 'static'. They will not contain any
  1423. definitions of any functions declared 'extern inline'.
  1424. '__GNUC_STDC_INLINE__'
  1425. GCC defines this macro if functions declared 'inline' will be
  1426. handled according to the ISO C99 or later standards. Object files
  1427. will contain externally visible definitions of all functions
  1428. declared 'extern inline'. They will not contain definitions of any
  1429. functions declared 'inline' without 'extern'.
  1430. If this macro is defined, GCC supports the 'gnu_inline' function
  1431. attribute as a way to always get the gnu90 behavior.
  1432. '__CHAR_UNSIGNED__'
  1433. GCC defines this macro if and only if the data type 'char' is
  1434. unsigned on the target machine. It exists to cause the standard
  1435. header file 'limits.h' to work correctly. You should not use this
  1436. macro yourself; instead, refer to the standard macros defined in
  1437. 'limits.h'.
  1438. '__WCHAR_UNSIGNED__'
  1439. Like '__CHAR_UNSIGNED__', this macro is defined if and only if the
  1440. data type 'wchar_t' is unsigned and the front-end is in C++ mode.
  1441. '__REGISTER_PREFIX__'
  1442. This macro expands to a single token (not a string constant) which
  1443. is the prefix applied to CPU register names in assembly language
  1444. for this target. You can use it to write assembly that is usable
  1445. in multiple environments. For example, in the 'm68k-aout'
  1446. environment it expands to nothing, but in the 'm68k-coff'
  1447. environment it expands to a single '%'.
  1448. '__USER_LABEL_PREFIX__'
  1449. This macro expands to a single token which is the prefix applied to
  1450. user labels (symbols visible to C code) in assembly. For example,
  1451. in the 'm68k-aout' environment it expands to an '_', but in the
  1452. 'm68k-coff' environment it expands to nothing.
  1453. This macro will have the correct definition even if
  1454. '-f(no-)underscores' is in use, but it will not be correct if
  1455. target-specific options that adjust this prefix are used (e.g. the
  1456. OSF/rose '-mno-underscores' option).
  1457. '__SIZE_TYPE__'
  1458. '__PTRDIFF_TYPE__'
  1459. '__WCHAR_TYPE__'
  1460. '__WINT_TYPE__'
  1461. '__INTMAX_TYPE__'
  1462. '__UINTMAX_TYPE__'
  1463. '__SIG_ATOMIC_TYPE__'
  1464. '__INT8_TYPE__'
  1465. '__INT16_TYPE__'
  1466. '__INT32_TYPE__'
  1467. '__INT64_TYPE__'
  1468. '__UINT8_TYPE__'
  1469. '__UINT16_TYPE__'
  1470. '__UINT32_TYPE__'
  1471. '__UINT64_TYPE__'
  1472. '__INT_LEAST8_TYPE__'
  1473. '__INT_LEAST16_TYPE__'
  1474. '__INT_LEAST32_TYPE__'
  1475. '__INT_LEAST64_TYPE__'
  1476. '__UINT_LEAST8_TYPE__'
  1477. '__UINT_LEAST16_TYPE__'
  1478. '__UINT_LEAST32_TYPE__'
  1479. '__UINT_LEAST64_TYPE__'
  1480. '__INT_FAST8_TYPE__'
  1481. '__INT_FAST16_TYPE__'
  1482. '__INT_FAST32_TYPE__'
  1483. '__INT_FAST64_TYPE__'
  1484. '__UINT_FAST8_TYPE__'
  1485. '__UINT_FAST16_TYPE__'
  1486. '__UINT_FAST32_TYPE__'
  1487. '__UINT_FAST64_TYPE__'
  1488. '__INTPTR_TYPE__'
  1489. '__UINTPTR_TYPE__'
  1490. These macros are defined to the correct underlying types for the
  1491. 'size_t', 'ptrdiff_t', 'wchar_t', 'wint_t', 'intmax_t',
  1492. 'uintmax_t', 'sig_atomic_t', 'int8_t', 'int16_t', 'int32_t',
  1493. 'int64_t', 'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t',
  1494. 'int_least8_t', 'int_least16_t', 'int_least32_t', 'int_least64_t',
  1495. 'uint_least8_t', 'uint_least16_t', 'uint_least32_t',
  1496. 'uint_least64_t', 'int_fast8_t', 'int_fast16_t', 'int_fast32_t',
  1497. 'int_fast64_t', 'uint_fast8_t', 'uint_fast16_t', 'uint_fast32_t',
  1498. 'uint_fast64_t', 'intptr_t', and 'uintptr_t' typedefs,
  1499. respectively. They exist to make the standard header files
  1500. 'stddef.h', 'stdint.h', and 'wchar.h' work correctly. You should
  1501. not use these macros directly; instead, include the appropriate
  1502. headers and use the typedefs. Some of these macros may not be
  1503. defined on particular systems if GCC does not provide a 'stdint.h'
  1504. header on those systems.
  1505. '__CHAR_BIT__'
  1506. Defined to the number of bits used in the representation of the
  1507. 'char' data type. It exists to make the standard header given
  1508. numerical limits work correctly. You should not use this macro
  1509. directly; instead, include the appropriate headers.
  1510. '__SCHAR_MAX__'
  1511. '__WCHAR_MAX__'
  1512. '__SHRT_MAX__'
  1513. '__INT_MAX__'
  1514. '__LONG_MAX__'
  1515. '__LONG_LONG_MAX__'
  1516. '__WINT_MAX__'
  1517. '__SIZE_MAX__'
  1518. '__PTRDIFF_MAX__'
  1519. '__INTMAX_MAX__'
  1520. '__UINTMAX_MAX__'
  1521. '__SIG_ATOMIC_MAX__'
  1522. '__INT8_MAX__'
  1523. '__INT16_MAX__'
  1524. '__INT32_MAX__'
  1525. '__INT64_MAX__'
  1526. '__UINT8_MAX__'
  1527. '__UINT16_MAX__'
  1528. '__UINT32_MAX__'
  1529. '__UINT64_MAX__'
  1530. '__INT_LEAST8_MAX__'
  1531. '__INT_LEAST16_MAX__'
  1532. '__INT_LEAST32_MAX__'
  1533. '__INT_LEAST64_MAX__'
  1534. '__UINT_LEAST8_MAX__'
  1535. '__UINT_LEAST16_MAX__'
  1536. '__UINT_LEAST32_MAX__'
  1537. '__UINT_LEAST64_MAX__'
  1538. '__INT_FAST8_MAX__'
  1539. '__INT_FAST16_MAX__'
  1540. '__INT_FAST32_MAX__'
  1541. '__INT_FAST64_MAX__'
  1542. '__UINT_FAST8_MAX__'
  1543. '__UINT_FAST16_MAX__'
  1544. '__UINT_FAST32_MAX__'
  1545. '__UINT_FAST64_MAX__'
  1546. '__INTPTR_MAX__'
  1547. '__UINTPTR_MAX__'
  1548. '__WCHAR_MIN__'
  1549. '__WINT_MIN__'
  1550. '__SIG_ATOMIC_MIN__'
  1551. Defined to the maximum value of the 'signed char', 'wchar_t',
  1552. 'signed short', 'signed int', 'signed long', 'signed long long',
  1553. 'wint_t', 'size_t', 'ptrdiff_t', 'intmax_t', 'uintmax_t',
  1554. 'sig_atomic_t', 'int8_t', 'int16_t', 'int32_t', 'int64_t',
  1555. 'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t', 'int_least8_t',
  1556. 'int_least16_t', 'int_least32_t', 'int_least64_t', 'uint_least8_t',
  1557. 'uint_least16_t', 'uint_least32_t', 'uint_least64_t',
  1558. 'int_fast8_t', 'int_fast16_t', 'int_fast32_t', 'int_fast64_t',
  1559. 'uint_fast8_t', 'uint_fast16_t', 'uint_fast32_t', 'uint_fast64_t',
  1560. 'intptr_t', and 'uintptr_t' types and to the minimum value of the
  1561. 'wchar_t', 'wint_t', and 'sig_atomic_t' types respectively. They
  1562. exist to make the standard header given numerical limits work
  1563. correctly. You should not use these macros directly; instead,
  1564. include the appropriate headers. Some of these macros may not be
  1565. defined on particular systems if GCC does not provide a 'stdint.h'
  1566. header on those systems.
  1567. '__INT8_C'
  1568. '__INT16_C'
  1569. '__INT32_C'
  1570. '__INT64_C'
  1571. '__UINT8_C'
  1572. '__UINT16_C'
  1573. '__UINT32_C'
  1574. '__UINT64_C'
  1575. '__INTMAX_C'
  1576. '__UINTMAX_C'
  1577. Defined to implementations of the standard 'stdint.h' macros with
  1578. the same names without the leading '__'. They exist the make the
  1579. implementation of that header work correctly. You should not use
  1580. these macros directly; instead, include the appropriate headers.
  1581. Some of these macros may not be defined on particular systems if
  1582. GCC does not provide a 'stdint.h' header on those systems.
  1583. '__SCHAR_WIDTH__'
  1584. '__SHRT_WIDTH__'
  1585. '__INT_WIDTH__'
  1586. '__LONG_WIDTH__'
  1587. '__LONG_LONG_WIDTH__'
  1588. '__PTRDIFF_WIDTH__'
  1589. '__SIG_ATOMIC_WIDTH__'
  1590. '__SIZE_WIDTH__'
  1591. '__WCHAR_WIDTH__'
  1592. '__WINT_WIDTH__'
  1593. '__INT_LEAST8_WIDTH__'
  1594. '__INT_LEAST16_WIDTH__'
  1595. '__INT_LEAST32_WIDTH__'
  1596. '__INT_LEAST64_WIDTH__'
  1597. '__INT_FAST8_WIDTH__'
  1598. '__INT_FAST16_WIDTH__'
  1599. '__INT_FAST32_WIDTH__'
  1600. '__INT_FAST64_WIDTH__'
  1601. '__INTPTR_WIDTH__'
  1602. '__INTMAX_WIDTH__'
  1603. Defined to the bit widths of the corresponding types. They exist
  1604. to make the implementations of 'limits.h' and 'stdint.h' behave
  1605. correctly. You should not use these macros directly; instead,
  1606. include the appropriate headers. Some of these macros may not be
  1607. defined on particular systems if GCC does not provide a 'stdint.h'
  1608. header on those systems.
  1609. '__SIZEOF_INT__'
  1610. '__SIZEOF_LONG__'
  1611. '__SIZEOF_LONG_LONG__'
  1612. '__SIZEOF_SHORT__'
  1613. '__SIZEOF_POINTER__'
  1614. '__SIZEOF_FLOAT__'
  1615. '__SIZEOF_DOUBLE__'
  1616. '__SIZEOF_LONG_DOUBLE__'
  1617. '__SIZEOF_SIZE_T__'
  1618. '__SIZEOF_WCHAR_T__'
  1619. '__SIZEOF_WINT_T__'
  1620. '__SIZEOF_PTRDIFF_T__'
  1621. Defined to the number of bytes of the C standard data types: 'int',
  1622. 'long', 'long long', 'short', 'void *', 'float', 'double', 'long
  1623. double', 'size_t', 'wchar_t', 'wint_t' and 'ptrdiff_t'.
  1624. '__BYTE_ORDER__'
  1625. '__ORDER_LITTLE_ENDIAN__'
  1626. '__ORDER_BIG_ENDIAN__'
  1627. '__ORDER_PDP_ENDIAN__'
  1628. '__BYTE_ORDER__' is defined to one of the values
  1629. '__ORDER_LITTLE_ENDIAN__', '__ORDER_BIG_ENDIAN__', or
  1630. '__ORDER_PDP_ENDIAN__' to reflect the layout of multi-byte and
  1631. multi-word quantities in memory. If '__BYTE_ORDER__' is equal to
  1632. '__ORDER_LITTLE_ENDIAN__' or '__ORDER_BIG_ENDIAN__', then
  1633. multi-byte and multi-word quantities are laid out identically: the
  1634. byte (word) at the lowest address is the least significant or most
  1635. significant byte (word) of the quantity, respectively. If
  1636. '__BYTE_ORDER__' is equal to '__ORDER_PDP_ENDIAN__', then bytes in
  1637. 16-bit words are laid out in a little-endian fashion, whereas the
  1638. 16-bit subwords of a 32-bit quantity are laid out in big-endian
  1639. fashion.
  1640. You should use these macros for testing like this:
  1641. /* Test for a little-endian machine */
  1642. #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
  1643. '__FLOAT_WORD_ORDER__'
  1644. '__FLOAT_WORD_ORDER__' is defined to one of the values
  1645. '__ORDER_LITTLE_ENDIAN__' or '__ORDER_BIG_ENDIAN__' to reflect the
  1646. layout of the words of multi-word floating-point quantities.
  1647. '__DEPRECATED'
  1648. This macro is defined, with value 1, when compiling a C++ source
  1649. file with warnings about deprecated constructs enabled. These
  1650. warnings are enabled by default, but can be disabled with
  1651. '-Wno-deprecated'.
  1652. '__EXCEPTIONS'
  1653. This macro is defined, with value 1, when compiling a C++ source
  1654. file with exceptions enabled. If '-fno-exceptions' is used when
  1655. compiling the file, then this macro is not defined.
  1656. '__GXX_RTTI'
  1657. This macro is defined, with value 1, when compiling a C++ source
  1658. file with runtime type identification enabled. If '-fno-rtti' is
  1659. used when compiling the file, then this macro is not defined.
  1660. '__USING_SJLJ_EXCEPTIONS__'
  1661. This macro is defined, with value 1, if the compiler uses the old
  1662. mechanism based on 'setjmp' and 'longjmp' for exception handling.
  1663. '__GXX_EXPERIMENTAL_CXX0X__'
  1664. This macro is defined when compiling a C++ source file with the
  1665. option '-std=c++0x' or '-std=gnu++0x'. It indicates that some
  1666. features likely to be included in C++0x are available. Note that
  1667. these features are experimental, and may change or be removed in
  1668. future versions of GCC.
  1669. '__GXX_WEAK__'
  1670. This macro is defined when compiling a C++ source file. It has the
  1671. value 1 if the compiler will use weak symbols, COMDAT sections, or
  1672. other similar techniques to collapse symbols with "vague linkage"
  1673. that are defined in multiple translation units. If the compiler
  1674. will not collapse such symbols, this macro is defined with value 0.
  1675. In general, user code should not need to make use of this macro;
  1676. the purpose of this macro is to ease implementation of the C++
  1677. runtime library provided with G++.
  1678. '__NEXT_RUNTIME__'
  1679. This macro is defined, with value 1, if (and only if) the NeXT
  1680. runtime (as in '-fnext-runtime') is in use for Objective-C. If the
  1681. GNU runtime is used, this macro is not defined, so that you can use
  1682. this macro to determine which runtime (NeXT or GNU) is being used.
  1683. '__LP64__'
  1684. '_LP64'
  1685. These macros are defined, with value 1, if (and only if) the
  1686. compilation is for a target where 'long int' and pointer both use
  1687. 64-bits and 'int' uses 32-bit.
  1688. '__SSP__'
  1689. This macro is defined, with value 1, when '-fstack-protector' is in
  1690. use.
  1691. '__SSP_ALL__'
  1692. This macro is defined, with value 2, when '-fstack-protector-all'
  1693. is in use.
  1694. '__SSP_STRONG__'
  1695. This macro is defined, with value 3, when
  1696. '-fstack-protector-strong' is in use.
  1697. '__SSP_EXPLICIT__'
  1698. This macro is defined, with value 4, when
  1699. '-fstack-protector-explicit' is in use.
  1700. '__SANITIZE_ADDRESS__'
  1701. This macro is defined, with value 1, when '-fsanitize=address' or
  1702. '-fsanitize=kernel-address' are in use.
  1703. '__SANITIZE_THREAD__'
  1704. This macro is defined, with value 1, when '-fsanitize=thread' is in
  1705. use.
  1706. '__TIMESTAMP__'
  1707. This macro expands to a string constant that describes the date and
  1708. time of the last modification of the current source file. The
  1709. string constant contains abbreviated day of the week, month, day of
  1710. the month, time in hh:mm:ss form, year and looks like
  1711. '"Sun Sep 16 01:03:52 1973"'. If the day of the month is less than
  1712. 10, it is padded with a space on the left.
  1713. If GCC cannot determine the current date, it will emit a warning
  1714. message (once per compilation) and '__TIMESTAMP__' will expand to
  1715. '"??? ??? ?? ??:??:?? ????"'.
  1716. '__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1'
  1717. '__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2'
  1718. '__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4'
  1719. '__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8'
  1720. '__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16'
  1721. These macros are defined when the target processor supports atomic
  1722. compare and swap operations on operands 1, 2, 4, 8 or 16 bytes in
  1723. length, respectively.
  1724. '__GCC_HAVE_DWARF2_CFI_ASM'
  1725. This macro is defined when the compiler is emitting DWARF CFI
  1726. directives to the assembler. When this is defined, it is possible
  1727. to emit those same directives in inline assembly.
  1728. '__FP_FAST_FMA'
  1729. '__FP_FAST_FMAF'
  1730. '__FP_FAST_FMAL'
  1731. These macros are defined with value 1 if the backend supports the
  1732. 'fma', 'fmaf', and 'fmal' builtin functions, so that the include
  1733. file 'math.h' can define the macros 'FP_FAST_FMA', 'FP_FAST_FMAF',
  1734. and 'FP_FAST_FMAL' for compatibility with the 1999 C standard.
  1735. '__GCC_IEC_559'
  1736. This macro is defined to indicate the intended level of support for
  1737. IEEE 754 (IEC 60559) floating-point arithmetic. It expands to a
  1738. nonnegative integer value. If 0, it indicates that the combination
  1739. of the compiler configuration and the command-line options is not
  1740. intended to support IEEE 754 arithmetic for 'float' and 'double' as
  1741. defined in C99 and C11 Annex F (for example, that the standard
  1742. rounding modes and exceptions are not supported, or that
  1743. optimizations are enabled that conflict with IEEE 754 semantics).
  1744. If 1, it indicates that IEEE 754 arithmetic is intended to be
  1745. supported; this does not mean that all relevant language features
  1746. are supported by GCC. If 2 or more, it additionally indicates
  1747. support for IEEE 754-2008 (in particular, that the binary encodings
  1748. for quiet and signaling NaNs are as specified in IEEE 754-2008).
  1749. This macro does not indicate the default state of command-line
  1750. options that control optimizations that C99 and C11 permit to be
  1751. controlled by standard pragmas, where those standards do not
  1752. require a particular default state. It does not indicate whether
  1753. optimizations respect signaling NaN semantics (the macro for that
  1754. is '__SUPPORT_SNAN__'). It does not indicate support for decimal
  1755. floating point or the IEEE 754 binary16 and binary128 types.
  1756. '__GCC_IEC_559_COMPLEX'
  1757. This macro is defined to indicate the intended level of support for
  1758. IEEE 754 (IEC 60559) floating-point arithmetic for complex numbers,
  1759. as defined in C99 and C11 Annex G. It expands to a nonnegative
  1760. integer value. If 0, it indicates that the combination of the
  1761. compiler configuration and the command-line options is not intended
  1762. to support Annex G requirements (for example, because
  1763. '-fcx-limited-range' was used). If 1 or more, it indicates that it
  1764. is intended to support those requirements; this does not mean that
  1765. all relevant language features are supported by GCC.
  1766. '__NO_MATH_ERRNO__'
  1767. This macro is defined if '-fno-math-errno' is used, or enabled by
  1768. another option such as '-ffast-math' or by default.
  1769. 
  1770. File: cpp.info, Node: System-specific Predefined Macros, Next: C++ Named Operators, Prev: Common Predefined Macros, Up: Predefined Macros
  1771. 3.7.3 System-specific Predefined Macros
  1772. ---------------------------------------
  1773. The C preprocessor normally predefines several macros that indicate what
  1774. type of system and machine is in use. They are obviously different on
  1775. each target supported by GCC. This manual, being for all systems and
  1776. machines, cannot tell you what their names are, but you can use 'cpp
  1777. -dM' to see them all. *Note Invocation::. All system-specific
  1778. predefined macros expand to a constant value, so you can test them with
  1779. either '#ifdef' or '#if'.
  1780. The C standard requires that all system-specific macros be part of
  1781. the "reserved namespace". All names which begin with two underscores,
  1782. or an underscore and a capital letter, are reserved for the compiler and
  1783. library to use as they wish. However, historically system-specific
  1784. macros have had names with no special prefix; for instance, it is common
  1785. to find 'unix' defined on Unix systems. For all such macros, GCC
  1786. provides a parallel macro with two underscores added at the beginning
  1787. and the end. If 'unix' is defined, '__unix__' will be defined too.
  1788. There will never be more than two underscores; the parallel of '_mips'
  1789. is '__mips__'.
  1790. When the '-ansi' option, or any '-std' option that requests strict
  1791. conformance, is given to the compiler, all the system-specific
  1792. predefined macros outside the reserved namespace are suppressed. The
  1793. parallel macros, inside the reserved namespace, remain defined.
  1794. We are slowly phasing out all predefined macros which are outside the
  1795. reserved namespace. You should never use them in new programs, and we
  1796. encourage you to correct older code to use the parallel macros whenever
  1797. you find it. We don't recommend you use the system-specific macros that
  1798. are in the reserved namespace, either. It is better in the long run to
  1799. check specifically for features you need, using a tool such as
  1800. 'autoconf'.
  1801. 
  1802. File: cpp.info, Node: C++ Named Operators, Prev: System-specific Predefined Macros, Up: Predefined Macros
  1803. 3.7.4 C++ Named Operators
  1804. -------------------------
  1805. In C++, there are eleven keywords which are simply alternate spellings
  1806. of operators normally written with punctuation. These keywords are
  1807. treated as such even in the preprocessor. They function as operators in
  1808. '#if', and they cannot be defined as macros or poisoned. In C, you can
  1809. request that those keywords take their C++ meaning by including
  1810. 'iso646.h'. That header defines each one as a normal object-like macro
  1811. expanding to the appropriate punctuator.
  1812. These are the named operators and their corresponding punctuators:
  1813. Named Operator Punctuator
  1814. 'and' '&&'
  1815. 'and_eq' '&='
  1816. 'bitand' '&'
  1817. 'bitor' '|'
  1818. 'compl' '~'
  1819. 'not' '!'
  1820. 'not_eq' '!='
  1821. 'or' '||'
  1822. 'or_eq' '|='
  1823. 'xor' '^'
  1824. 'xor_eq' '^='
  1825. 
  1826. File: cpp.info, Node: Undefining and Redefining Macros, Next: Directives Within Macro Arguments, Prev: Predefined Macros, Up: Macros
  1827. 3.8 Undefining and Redefining Macros
  1828. ====================================
  1829. If a macro ceases to be useful, it may be "undefined" with the '#undef'
  1830. directive. '#undef' takes a single argument, the name of the macro to
  1831. undefine. You use the bare macro name, even if the macro is
  1832. function-like. It is an error if anything appears on the line after the
  1833. macro name. '#undef' has no effect if the name is not a macro.
  1834. #define FOO 4
  1835. x = FOO; ==> x = 4;
  1836. #undef FOO
  1837. x = FOO; ==> x = FOO;
  1838. Once a macro has been undefined, that identifier may be "redefined"
  1839. as a macro by a subsequent '#define' directive. The new definition need
  1840. not have any resemblance to the old definition.
  1841. However, if an identifier which is currently a macro is redefined,
  1842. then the new definition must be "effectively the same" as the old one.
  1843. Two macro definitions are effectively the same if:
  1844. * Both are the same type of macro (object- or function-like).
  1845. * All the tokens of the replacement list are the same.
  1846. * If there are any parameters, they are the same.
  1847. * Whitespace appears in the same places in both. It need not be
  1848. exactly the same amount of whitespace, though. Remember that
  1849. comments count as whitespace.
  1850. These definitions are effectively the same:
  1851. #define FOUR (2 + 2)
  1852. #define FOUR (2 + 2)
  1853. #define FOUR (2 /* two */ + 2)
  1854. but these are not:
  1855. #define FOUR (2 + 2)
  1856. #define FOUR ( 2+2 )
  1857. #define FOUR (2 * 2)
  1858. #define FOUR(score,and,seven,years,ago) (2 + 2)
  1859. If a macro is redefined with a definition that is not effectively the
  1860. same as the old one, the preprocessor issues a warning and changes the
  1861. macro to use the new definition. If the new definition is effectively
  1862. the same, the redefinition is silently ignored. This allows, for
  1863. instance, two different headers to define a common macro. The
  1864. preprocessor will only complain if the definitions do not match.
  1865. 
  1866. File: cpp.info, Node: Directives Within Macro Arguments, Next: Macro Pitfalls, Prev: Undefining and Redefining Macros, Up: Macros
  1867. 3.9 Directives Within Macro Arguments
  1868. =====================================
  1869. Occasionally it is convenient to use preprocessor directives within the
  1870. arguments of a macro. The C and C++ standards declare that behavior in
  1871. these cases is undefined. GNU CPP processes arbitrary directives within
  1872. macro arguments in exactly the same way as it would have processed the
  1873. directive were the function-like macro invocation not present.
  1874. If, within a macro invocation, that macro is redefined, then the new
  1875. definition takes effect in time for argument pre-expansion, but the
  1876. original definition is still used for argument replacement. Here is a
  1877. pathological example:
  1878. #define f(x) x x
  1879. f (1
  1880. #undef f
  1881. #define f 2
  1882. f)
  1883. which expands to
  1884. 1 2 1 2
  1885. with the semantics described above.
  1886. 
  1887. File: cpp.info, Node: Macro Pitfalls, Prev: Directives Within Macro Arguments, Up: Macros
  1888. 3.10 Macro Pitfalls
  1889. ===================
  1890. In this section we describe some special rules that apply to macros and
  1891. macro expansion, and point out certain cases in which the rules have
  1892. counter-intuitive consequences that you must watch out for.
  1893. * Menu:
  1894. * Misnesting::
  1895. * Operator Precedence Problems::
  1896. * Swallowing the Semicolon::
  1897. * Duplication of Side Effects::
  1898. * Self-Referential Macros::
  1899. * Argument Prescan::
  1900. * Newlines in Arguments::
  1901. 
  1902. File: cpp.info, Node: Misnesting, Next: Operator Precedence Problems, Up: Macro Pitfalls
  1903. 3.10.1 Misnesting
  1904. -----------------
  1905. When a macro is called with arguments, the arguments are substituted
  1906. into the macro body and the result is checked, together with the rest of
  1907. the input file, for more macro calls. It is possible to piece together
  1908. a macro call coming partially from the macro body and partially from the
  1909. arguments. For example,
  1910. #define twice(x) (2*(x))
  1911. #define call_with_1(x) x(1)
  1912. call_with_1 (twice)
  1913. ==> twice(1)
  1914. ==> (2*(1))
  1915. Macro definitions do not have to have balanced parentheses. By
  1916. writing an unbalanced open parenthesis in a macro body, it is possible
  1917. to create a macro call that begins inside the macro body but ends
  1918. outside of it. For example,
  1919. #define strange(file) fprintf (file, "%s %d",
  1920. ...
  1921. strange(stderr) p, 35)
  1922. ==> fprintf (stderr, "%s %d", p, 35)
  1923. The ability to piece together a macro call can be useful, but the use
  1924. of unbalanced open parentheses in a macro body is just confusing, and
  1925. should be avoided.
  1926. 
  1927. File: cpp.info, Node: Operator Precedence Problems, Next: Swallowing the Semicolon, Prev: Misnesting, Up: Macro Pitfalls
  1928. 3.10.2 Operator Precedence Problems
  1929. -----------------------------------
  1930. You may have noticed that in most of the macro definition examples shown
  1931. above, each occurrence of a macro argument name had parentheses around
  1932. it. In addition, another pair of parentheses usually surround the
  1933. entire macro definition. Here is why it is best to write macros that
  1934. way.
  1935. Suppose you define a macro as follows,
  1936. #define ceil_div(x, y) (x + y - 1) / y
  1937. whose purpose is to divide, rounding up. (One use for this operation is
  1938. to compute how many 'int' objects are needed to hold a certain number of
  1939. 'char' objects.) Then suppose it is used as follows:
  1940. a = ceil_div (b & c, sizeof (int));
  1941. ==> a = (b & c + sizeof (int) - 1) / sizeof (int);
  1942. This does not do what is intended. The operator-precedence rules of C
  1943. make it equivalent to this:
  1944. a = (b & (c + sizeof (int) - 1)) / sizeof (int);
  1945. What we want is this:
  1946. a = ((b & c) + sizeof (int) - 1)) / sizeof (int);
  1947. Defining the macro as
  1948. #define ceil_div(x, y) ((x) + (y) - 1) / (y)
  1949. provides the desired result.
  1950. Unintended grouping can result in another way. Consider 'sizeof
  1951. ceil_div(1, 2)'. That has the appearance of a C expression that would
  1952. compute the size of the type of 'ceil_div (1, 2)', but in fact it means
  1953. something very different. Here is what it expands to:
  1954. sizeof ((1) + (2) - 1) / (2)
  1955. This would take the size of an integer and divide it by two. The
  1956. precedence rules have put the division outside the 'sizeof' when it was
  1957. intended to be inside.
  1958. Parentheses around the entire macro definition prevent such problems.
  1959. Here, then, is the recommended way to define 'ceil_div':
  1960. #define ceil_div(x, y) (((x) + (y) - 1) / (y))
  1961. 
  1962. File: cpp.info, Node: Swallowing the Semicolon, Next: Duplication of Side Effects, Prev: Operator Precedence Problems, Up: Macro Pitfalls
  1963. 3.10.3 Swallowing the Semicolon
  1964. -------------------------------
  1965. Often it is desirable to define a macro that expands into a compound
  1966. statement. Consider, for example, the following macro, that advances a
  1967. pointer (the argument 'p' says where to find it) across whitespace
  1968. characters:
  1969. #define SKIP_SPACES(p, limit) \
  1970. { char *lim = (limit); \
  1971. while (p < lim) { \
  1972. if (*p++ != ' ') { \
  1973. p--; break; }}}
  1974. Here backslash-newline is used to split the macro definition, which must
  1975. be a single logical line, so that it resembles the way such code would
  1976. be laid out if not part of a macro definition.
  1977. A call to this macro might be 'SKIP_SPACES (p, lim)'. Strictly
  1978. speaking, the call expands to a compound statement, which is a complete
  1979. statement with no need for a semicolon to end it. However, since it
  1980. looks like a function call, it minimizes confusion if you can use it
  1981. like a function call, writing a semicolon afterward, as in 'SKIP_SPACES
  1982. (p, lim);'
  1983. This can cause trouble before 'else' statements, because the
  1984. semicolon is actually a null statement. Suppose you write
  1985. if (*p != 0)
  1986. SKIP_SPACES (p, lim);
  1987. else ...
  1988. The presence of two statements--the compound statement and a null
  1989. statement--in between the 'if' condition and the 'else' makes invalid C
  1990. code.
  1991. The definition of the macro 'SKIP_SPACES' can be altered to solve
  1992. this problem, using a 'do ... while' statement. Here is how:
  1993. #define SKIP_SPACES(p, limit) \
  1994. do { char *lim = (limit); \
  1995. while (p < lim) { \
  1996. if (*p++ != ' ') { \
  1997. p--; break; }}} \
  1998. while (0)
  1999. Now 'SKIP_SPACES (p, lim);' expands into
  2000. do {...} while (0);
  2001. which is one statement. The loop executes exactly once; most compilers
  2002. generate no extra code for it.
  2003. 
  2004. File: cpp.info, Node: Duplication of Side Effects, Next: Self-Referential Macros, Prev: Swallowing the Semicolon, Up: Macro Pitfalls
  2005. 3.10.4 Duplication of Side Effects
  2006. ----------------------------------
  2007. Many C programs define a macro 'min', for "minimum", like this:
  2008. #define min(X, Y) ((X) < (Y) ? (X) : (Y))
  2009. When you use this macro with an argument containing a side effect, as
  2010. shown here,
  2011. next = min (x + y, foo (z));
  2012. it expands as follows:
  2013. next = ((x + y) < (foo (z)) ? (x + y) : (foo (z)));
  2014. where 'x + y' has been substituted for 'X' and 'foo (z)' for 'Y'.
  2015. The function 'foo' is used only once in the statement as it appears
  2016. in the program, but the expression 'foo (z)' has been substituted twice
  2017. into the macro expansion. As a result, 'foo' might be called two times
  2018. when the statement is executed. If it has side effects or if it takes a
  2019. long time to compute, the results might not be what you intended. We
  2020. say that 'min' is an "unsafe" macro.
  2021. The best solution to this problem is to define 'min' in a way that
  2022. computes the value of 'foo (z)' only once. The C language offers no
  2023. standard way to do this, but it can be done with GNU extensions as
  2024. follows:
  2025. #define min(X, Y) \
  2026. ({ typeof (X) x_ = (X); \
  2027. typeof (Y) y_ = (Y); \
  2028. (x_ < y_) ? x_ : y_; })
  2029. The '({ ... })' notation produces a compound statement that acts as
  2030. an expression. Its value is the value of its last statement. This
  2031. permits us to define local variables and assign each argument to one.
  2032. The local variables have underscores after their names to reduce the
  2033. risk of conflict with an identifier of wider scope (it is impossible to
  2034. avoid this entirely). Now each argument is evaluated exactly once.
  2035. If you do not wish to use GNU C extensions, the only solution is to
  2036. be careful when _using_ the macro 'min'. For example, you can calculate
  2037. the value of 'foo (z)', save it in a variable, and use that variable in
  2038. 'min':
  2039. #define min(X, Y) ((X) < (Y) ? (X) : (Y))
  2040. ...
  2041. {
  2042. int tem = foo (z);
  2043. next = min (x + y, tem);
  2044. }
  2045. (where we assume that 'foo' returns type 'int').
  2046. 
  2047. File: cpp.info, Node: Self-Referential Macros, Next: Argument Prescan, Prev: Duplication of Side Effects, Up: Macro Pitfalls
  2048. 3.10.5 Self-Referential Macros
  2049. ------------------------------
  2050. A "self-referential" macro is one whose name appears in its definition.
  2051. Recall that all macro definitions are rescanned for more macros to
  2052. replace. If the self-reference were considered a use of the macro, it
  2053. would produce an infinitely large expansion. To prevent this, the
  2054. self-reference is not considered a macro call. It is passed into the
  2055. preprocessor output unchanged. Consider an example:
  2056. #define foo (4 + foo)
  2057. where 'foo' is also a variable in your program.
  2058. Following the ordinary rules, each reference to 'foo' will expand
  2059. into '(4 + foo)'; then this will be rescanned and will expand into '(4 +
  2060. (4 + foo))'; and so on until the computer runs out of memory.
  2061. The self-reference rule cuts this process short after one step, at
  2062. '(4 + foo)'. Therefore, this macro definition has the possibly useful
  2063. effect of causing the program to add 4 to the value of 'foo' wherever
  2064. 'foo' is referred to.
  2065. In most cases, it is a bad idea to take advantage of this feature. A
  2066. person reading the program who sees that 'foo' is a variable will not
  2067. expect that it is a macro as well. The reader will come across the
  2068. identifier 'foo' in the program and think its value should be that of
  2069. the variable 'foo', whereas in fact the value is four greater.
  2070. One common, useful use of self-reference is to create a macro which
  2071. expands to itself. If you write
  2072. #define EPERM EPERM
  2073. then the macro 'EPERM' expands to 'EPERM'. Effectively, it is left
  2074. alone by the preprocessor whenever it's used in running text. You can
  2075. tell that it's a macro with '#ifdef'. You might do this if you want to
  2076. define numeric constants with an 'enum', but have '#ifdef' be true for
  2077. each constant.
  2078. If a macro 'x' expands to use a macro 'y', and the expansion of 'y'
  2079. refers to the macro 'x', that is an "indirect self-reference" of 'x'.
  2080. 'x' is not expanded in this case either. Thus, if we have
  2081. #define x (4 + y)
  2082. #define y (2 * x)
  2083. then 'x' and 'y' expand as follows:
  2084. x ==> (4 + y)
  2085. ==> (4 + (2 * x))
  2086. y ==> (2 * x)
  2087. ==> (2 * (4 + y))
  2088. Each macro is expanded when it appears in the definition of the other
  2089. macro, but not when it indirectly appears in its own definition.
  2090. 
  2091. File: cpp.info, Node: Argument Prescan, Next: Newlines in Arguments, Prev: Self-Referential Macros, Up: Macro Pitfalls
  2092. 3.10.6 Argument Prescan
  2093. -----------------------
  2094. Macro arguments are completely macro-expanded before they are
  2095. substituted into a macro body, unless they are stringized or pasted with
  2096. other tokens. After substitution, the entire macro body, including the
  2097. substituted arguments, is scanned again for macros to be expanded. The
  2098. result is that the arguments are scanned _twice_ to expand macro calls
  2099. in them.
  2100. Most of the time, this has no effect. If the argument contained any
  2101. macro calls, they are expanded during the first scan. The result
  2102. therefore contains no macro calls, so the second scan does not change
  2103. it. If the argument were substituted as given, with no prescan, the
  2104. single remaining scan would find the same macro calls and produce the
  2105. same results.
  2106. You might expect the double scan to change the results when a
  2107. self-referential macro is used in an argument of another macro (*note
  2108. Self-Referential Macros::): the self-referential macro would be expanded
  2109. once in the first scan, and a second time in the second scan. However,
  2110. this is not what happens. The self-references that do not expand in the
  2111. first scan are marked so that they will not expand in the second scan
  2112. either.
  2113. You might wonder, "Why mention the prescan, if it makes no
  2114. difference? And why not skip it and make the preprocessor faster?" The
  2115. answer is that the prescan does make a difference in three special
  2116. cases:
  2117. * Nested calls to a macro.
  2118. We say that "nested" calls to a macro occur when a macro's argument
  2119. contains a call to that very macro. For example, if 'f' is a macro
  2120. that expects one argument, 'f (f (1))' is a nested pair of calls to
  2121. 'f'. The desired expansion is made by expanding 'f (1)' and
  2122. substituting that into the definition of 'f'. The prescan causes
  2123. the expected result to happen. Without the prescan, 'f (1)' itself
  2124. would be substituted as an argument, and the inner use of 'f' would
  2125. appear during the main scan as an indirect self-reference and would
  2126. not be expanded.
  2127. * Macros that call other macros that stringize or concatenate.
  2128. If an argument is stringized or concatenated, the prescan does not
  2129. occur. If you _want_ to expand a macro, then stringize or
  2130. concatenate its expansion, you can do that by causing one macro to
  2131. call another macro that does the stringizing or concatenation. For
  2132. instance, if you have
  2133. #define AFTERX(x) X_ ## x
  2134. #define XAFTERX(x) AFTERX(x)
  2135. #define TABLESIZE 1024
  2136. #define BUFSIZE TABLESIZE
  2137. then 'AFTERX(BUFSIZE)' expands to 'X_BUFSIZE', and
  2138. 'XAFTERX(BUFSIZE)' expands to 'X_1024'. (Not to 'X_TABLESIZE'.
  2139. Prescan always does a complete expansion.)
  2140. * Macros used in arguments, whose expansions contain unshielded
  2141. commas.
  2142. This can cause a macro expanded on the second scan to be called
  2143. with the wrong number of arguments. Here is an example:
  2144. #define foo a,b
  2145. #define bar(x) lose(x)
  2146. #define lose(x) (1 + (x))
  2147. We would like 'bar(foo)' to turn into '(1 + (foo))', which would
  2148. then turn into '(1 + (a,b))'. Instead, 'bar(foo)' expands into
  2149. 'lose(a,b)', and you get an error because 'lose' requires a single
  2150. argument. In this case, the problem is easily solved by the same
  2151. parentheses that ought to be used to prevent misnesting of
  2152. arithmetic operations:
  2153. #define foo (a,b)
  2154. or
  2155. #define bar(x) lose((x))
  2156. The extra pair of parentheses prevents the comma in 'foo''s
  2157. definition from being interpreted as an argument separator.
  2158. 
  2159. File: cpp.info, Node: Newlines in Arguments, Prev: Argument Prescan, Up: Macro Pitfalls
  2160. 3.10.7 Newlines in Arguments
  2161. ----------------------------
  2162. The invocation of a function-like macro can extend over many logical
  2163. lines. However, in the present implementation, the entire expansion
  2164. comes out on one line. Thus line numbers emitted by the compiler or
  2165. debugger refer to the line the invocation started on, which might be
  2166. different to the line containing the argument causing the problem.
  2167. Here is an example illustrating this:
  2168. #define ignore_second_arg(a,b,c) a; c
  2169. ignore_second_arg (foo (),
  2170. ignored (),
  2171. syntax error);
  2172. The syntax error triggered by the tokens 'syntax error' results in an
  2173. error message citing line three--the line of ignore_second_arg-- even
  2174. though the problematic code comes from line five.
  2175. We consider this a bug, and intend to fix it in the near future.
  2176. 
  2177. File: cpp.info, Node: Conditionals, Next: Diagnostics, Prev: Macros, Up: Top
  2178. 4 Conditionals
  2179. **************
  2180. A "conditional" is a directive that instructs the preprocessor to select
  2181. whether or not to include a chunk of code in the final token stream
  2182. passed to the compiler. Preprocessor conditionals can test arithmetic
  2183. expressions, or whether a name is defined as a macro, or both
  2184. simultaneously using the special 'defined' operator.
  2185. A conditional in the C preprocessor resembles in some ways an 'if'
  2186. statement in C, but it is important to understand the difference between
  2187. them. The condition in an 'if' statement is tested during the execution
  2188. of your program. Its purpose is to allow your program to behave
  2189. differently from run to run, depending on the data it is operating on.
  2190. The condition in a preprocessing conditional directive is tested when
  2191. your program is compiled. Its purpose is to allow different code to be
  2192. included in the program depending on the situation at the time of
  2193. compilation.
  2194. However, the distinction is becoming less clear. Modern compilers
  2195. often do test 'if' statements when a program is compiled, if their
  2196. conditions are known not to vary at run time, and eliminate code which
  2197. can never be executed. If you can count on your compiler to do this,
  2198. you may find that your program is more readable if you use 'if'
  2199. statements with constant conditions (perhaps determined by macros). Of
  2200. course, you can only use this to exclude code, not type definitions or
  2201. other preprocessing directives, and you can only do it if the code
  2202. remains syntactically valid when it is not to be used.
  2203. * Menu:
  2204. * Conditional Uses::
  2205. * Conditional Syntax::
  2206. * Deleted Code::
  2207. 
  2208. File: cpp.info, Node: Conditional Uses, Next: Conditional Syntax, Up: Conditionals
  2209. 4.1 Conditional Uses
  2210. ====================
  2211. There are three general reasons to use a conditional.
  2212. * A program may need to use different code depending on the machine
  2213. or operating system it is to run on. In some cases the code for
  2214. one operating system may be erroneous on another operating system;
  2215. for example, it might refer to data types or constants that do not
  2216. exist on the other system. When this happens, it is not enough to
  2217. avoid executing the invalid code. Its mere presence will cause the
  2218. compiler to reject the program. With a preprocessing conditional,
  2219. the offending code can be effectively excised from the program when
  2220. it is not valid.
  2221. * You may want to be able to compile the same source file into two
  2222. different programs. One version might make frequent time-consuming
  2223. consistency checks on its intermediate data, or print the values of
  2224. those data for debugging, and the other not.
  2225. * A conditional whose condition is always false is one way to exclude
  2226. code from the program but keep it as a sort of comment for future
  2227. reference.
  2228. Simple programs that do not need system-specific logic or complex
  2229. debugging hooks generally will not need to use preprocessing
  2230. conditionals.
  2231. 
  2232. File: cpp.info, Node: Conditional Syntax, Next: Deleted Code, Prev: Conditional Uses, Up: Conditionals
  2233. 4.2 Conditional Syntax
  2234. ======================
  2235. A conditional in the C preprocessor begins with a "conditional
  2236. directive": '#if', '#ifdef' or '#ifndef'.
  2237. * Menu:
  2238. * Ifdef::
  2239. * If::
  2240. * Defined::
  2241. * Else::
  2242. * Elif::
  2243. 
  2244. File: cpp.info, Node: Ifdef, Next: If, Up: Conditional Syntax
  2245. 4.2.1 Ifdef
  2246. -----------
  2247. The simplest sort of conditional is
  2248. #ifdef MACRO
  2249. CONTROLLED TEXT
  2250. #endif /* MACRO */
  2251. This block is called a "conditional group". CONTROLLED TEXT will be
  2252. included in the output of the preprocessor if and only if MACRO is
  2253. defined. We say that the conditional "succeeds" if MACRO is defined,
  2254. "fails" if it is not.
  2255. The CONTROLLED TEXT inside of a conditional can include preprocessing
  2256. directives. They are executed only if the conditional succeeds. You
  2257. can nest conditional groups inside other conditional groups, but they
  2258. must be completely nested. In other words, '#endif' always matches the
  2259. nearest '#ifdef' (or '#ifndef', or '#if'). Also, you cannot start a
  2260. conditional group in one file and end it in another.
  2261. Even if a conditional fails, the CONTROLLED TEXT inside it is still
  2262. run through initial transformations and tokenization. Therefore, it
  2263. must all be lexically valid C. Normally the only way this matters is
  2264. that all comments and string literals inside a failing conditional group
  2265. must still be properly ended.
  2266. The comment following the '#endif' is not required, but it is a good
  2267. practice if there is a lot of CONTROLLED TEXT, because it helps people
  2268. match the '#endif' to the corresponding '#ifdef'. Older programs
  2269. sometimes put MACRO directly after the '#endif' without enclosing it in
  2270. a comment. This is invalid code according to the C standard. CPP
  2271. accepts it with a warning. It never affects which '#ifndef' the
  2272. '#endif' matches.
  2273. Sometimes you wish to use some code if a macro is _not_ defined. You
  2274. can do this by writing '#ifndef' instead of '#ifdef'. One common use of
  2275. '#ifndef' is to include code only the first time a header file is
  2276. included. *Note Once-Only Headers::.
  2277. Macro definitions can vary between compilations for several reasons.
  2278. Here are some samples.
  2279. * Some macros are predefined on each kind of machine (*note
  2280. System-specific Predefined Macros::). This allows you to provide
  2281. code specially tuned for a particular machine.
  2282. * System header files define more macros, associated with the
  2283. features they implement. You can test these macros with
  2284. conditionals to avoid using a system feature on a machine where it
  2285. is not implemented.
  2286. * Macros can be defined or undefined with the '-D' and '-U'
  2287. command-line options when you compile the program. You can arrange
  2288. to compile the same source file into two different programs by
  2289. choosing a macro name to specify which program you want, writing
  2290. conditionals to test whether or how this macro is defined, and then
  2291. controlling the state of the macro with command-line options,
  2292. perhaps set in the Makefile. *Note Invocation::.
  2293. * Your program might have a special header file (often called
  2294. 'config.h') that is adjusted when the program is compiled. It can
  2295. define or not define macros depending on the features of the system
  2296. and the desired capabilities of the program. The adjustment can be
  2297. automated by a tool such as 'autoconf', or done by hand.
  2298. 
  2299. File: cpp.info, Node: If, Next: Defined, Prev: Ifdef, Up: Conditional Syntax
  2300. 4.2.2 If
  2301. --------
  2302. The '#if' directive allows you to test the value of an arithmetic
  2303. expression, rather than the mere existence of one macro. Its syntax is
  2304. #if EXPRESSION
  2305. CONTROLLED TEXT
  2306. #endif /* EXPRESSION */
  2307. EXPRESSION is a C expression of integer type, subject to stringent
  2308. restrictions. It may contain
  2309. * Integer constants.
  2310. * Character constants, which are interpreted as they would be in
  2311. normal code.
  2312. * Arithmetic operators for addition, subtraction, multiplication,
  2313. division, bitwise operations, shifts, comparisons, and logical
  2314. operations ('&&' and '||'). The latter two obey the usual
  2315. short-circuiting rules of standard C.
  2316. * Macros. All macros in the expression are expanded before actual
  2317. computation of the expression's value begins.
  2318. * Uses of the 'defined' operator, which lets you check whether macros
  2319. are defined in the middle of an '#if'.
  2320. * Identifiers that are not macros, which are all considered to be the
  2321. number zero. This allows you to write '#if MACRO' instead of
  2322. '#ifdef MACRO', if you know that MACRO, when defined, will always
  2323. have a nonzero value. Function-like macros used without their
  2324. function call parentheses are also treated as zero.
  2325. In some contexts this shortcut is undesirable. The '-Wundef'
  2326. option causes GCC to warn whenever it encounters an identifier
  2327. which is not a macro in an '#if'.
  2328. The preprocessor does not know anything about types in the language.
  2329. Therefore, 'sizeof' operators are not recognized in '#if', and neither
  2330. are 'enum' constants. They will be taken as identifiers which are not
  2331. macros, and replaced by zero. In the case of 'sizeof', this is likely
  2332. to cause the expression to be invalid.
  2333. The preprocessor calculates the value of EXPRESSION. It carries out
  2334. all calculations in the widest integer type known to the compiler; on
  2335. most machines supported by GCC this is 64 bits. This is not the same
  2336. rule as the compiler uses to calculate the value of a constant
  2337. expression, and may give different results in some cases. If the value
  2338. comes out to be nonzero, the '#if' succeeds and the CONTROLLED TEXT is
  2339. included; otherwise it is skipped.
  2340. 
  2341. File: cpp.info, Node: Defined, Next: Else, Prev: If, Up: Conditional Syntax
  2342. 4.2.3 Defined
  2343. -------------
  2344. The special operator 'defined' is used in '#if' and '#elif' expressions
  2345. to test whether a certain name is defined as a macro. 'defined NAME'
  2346. and 'defined (NAME)' are both expressions whose value is 1 if NAME is
  2347. defined as a macro at the current point in the program, and 0 otherwise.
  2348. Thus, '#if defined MACRO' is precisely equivalent to '#ifdef MACRO'.
  2349. 'defined' is useful when you wish to test more than one macro for
  2350. existence at once. For example,
  2351. #if defined (__vax__) || defined (__ns16000__)
  2352. would succeed if either of the names '__vax__' or '__ns16000__' is
  2353. defined as a macro.
  2354. Conditionals written like this:
  2355. #if defined BUFSIZE && BUFSIZE >= 1024
  2356. can generally be simplified to just '#if BUFSIZE >= 1024', since if
  2357. 'BUFSIZE' is not defined, it will be interpreted as having the value
  2358. zero.
  2359. If the 'defined' operator appears as a result of a macro expansion,
  2360. the C standard says the behavior is undefined. GNU cpp treats it as a
  2361. genuine 'defined' operator and evaluates it normally. It will warn
  2362. wherever your code uses this feature if you use the command-line option
  2363. '-Wpedantic', since other compilers may handle it differently. The
  2364. warning is also enabled by '-Wextra', and can also be enabled
  2365. individually with '-Wexpansion-to-defined'.
  2366. 
  2367. File: cpp.info, Node: Else, Next: Elif, Prev: Defined, Up: Conditional Syntax
  2368. 4.2.4 Else
  2369. ----------
  2370. The '#else' directive can be added to a conditional to provide
  2371. alternative text to be used if the condition fails. This is what it
  2372. looks like:
  2373. #if EXPRESSION
  2374. TEXT-IF-TRUE
  2375. #else /* Not EXPRESSION */
  2376. TEXT-IF-FALSE
  2377. #endif /* Not EXPRESSION */
  2378. If EXPRESSION is nonzero, the TEXT-IF-TRUE is included and the
  2379. TEXT-IF-FALSE is skipped. If EXPRESSION is zero, the opposite happens.
  2380. You can use '#else' with '#ifdef' and '#ifndef', too.
  2381. 
  2382. File: cpp.info, Node: Elif, Prev: Else, Up: Conditional Syntax
  2383. 4.2.5 Elif
  2384. ----------
  2385. One common case of nested conditionals is used to check for more than
  2386. two possible alternatives. For example, you might have
  2387. #if X == 1
  2388. ...
  2389. #else /* X != 1 */
  2390. #if X == 2
  2391. ...
  2392. #else /* X != 2 */
  2393. ...
  2394. #endif /* X != 2 */
  2395. #endif /* X != 1 */
  2396. Another conditional directive, '#elif', allows this to be abbreviated
  2397. as follows:
  2398. #if X == 1
  2399. ...
  2400. #elif X == 2
  2401. ...
  2402. #else /* X != 2 and X != 1*/
  2403. ...
  2404. #endif /* X != 2 and X != 1*/
  2405. '#elif' stands for "else if". Like '#else', it goes in the middle of
  2406. a conditional group and subdivides it; it does not require a matching
  2407. '#endif' of its own. Like '#if', the '#elif' directive includes an
  2408. expression to be tested. The text following the '#elif' is processed
  2409. only if the original '#if'-condition failed and the '#elif' condition
  2410. succeeds.
  2411. More than one '#elif' can go in the same conditional group. Then the
  2412. text after each '#elif' is processed only if the '#elif' condition
  2413. succeeds after the original '#if' and all previous '#elif' directives
  2414. within it have failed.
  2415. '#else' is allowed after any number of '#elif' directives, but
  2416. '#elif' may not follow '#else'.
  2417. 
  2418. File: cpp.info, Node: Deleted Code, Prev: Conditional Syntax, Up: Conditionals
  2419. 4.3 Deleted Code
  2420. ================
  2421. If you replace or delete a part of the program but want to keep the old
  2422. code around for future reference, you often cannot simply comment it
  2423. out. Block comments do not nest, so the first comment inside the old
  2424. code will end the commenting-out. The probable result is a flood of
  2425. syntax errors.
  2426. One way to avoid this problem is to use an always-false conditional
  2427. instead. For instance, put '#if 0' before the deleted code and '#endif'
  2428. after it. This works even if the code being turned off contains
  2429. conditionals, but they must be entire conditionals (balanced '#if' and
  2430. '#endif').
  2431. Some people use '#ifdef notdef' instead. This is risky, because
  2432. 'notdef' might be accidentally defined as a macro, and then the
  2433. conditional would succeed. '#if 0' can be counted on to fail.
  2434. Do not use '#if 0' for comments which are not C code. Use a real
  2435. comment, instead. The interior of '#if 0' must consist of complete
  2436. tokens; in particular, single-quote characters must balance. Comments
  2437. often contain unbalanced single-quote characters (known in English as
  2438. apostrophes). These confuse '#if 0'. They don't confuse '/*'.
  2439. 
  2440. File: cpp.info, Node: Diagnostics, Next: Line Control, Prev: Conditionals, Up: Top
  2441. 5 Diagnostics
  2442. *************
  2443. The directive '#error' causes the preprocessor to report a fatal error.
  2444. The tokens forming the rest of the line following '#error' are used as
  2445. the error message.
  2446. You would use '#error' inside of a conditional that detects a
  2447. combination of parameters which you know the program does not properly
  2448. support. For example, if you know that the program will not run
  2449. properly on a VAX, you might write
  2450. #ifdef __vax__
  2451. #error "Won't work on VAXen. See comments at get_last_object."
  2452. #endif
  2453. If you have several configuration parameters that must be set up by
  2454. the installation in a consistent way, you can use conditionals to detect
  2455. an inconsistency and report it with '#error'. For example,
  2456. #if !defined(FOO) && defined(BAR)
  2457. #error "BAR requires FOO."
  2458. #endif
  2459. The directive '#warning' is like '#error', but causes the
  2460. preprocessor to issue a warning and continue preprocessing. The tokens
  2461. following '#warning' are used as the warning message.
  2462. You might use '#warning' in obsolete header files, with a message
  2463. directing the user to the header file which should be used instead.
  2464. Neither '#error' nor '#warning' macro-expands its argument. Internal
  2465. whitespace sequences are each replaced with a single space. The line
  2466. must consist of complete tokens. It is wisest to make the argument of
  2467. these directives be a single string constant; this avoids problems with
  2468. apostrophes and the like.
  2469. 
  2470. File: cpp.info, Node: Line Control, Next: Pragmas, Prev: Diagnostics, Up: Top
  2471. 6 Line Control
  2472. **************
  2473. The C preprocessor informs the C compiler of the location in your source
  2474. code where each token came from. Presently, this is just the file name
  2475. and line number. All the tokens resulting from macro expansion are
  2476. reported as having appeared on the line of the source file where the
  2477. outermost macro was used. We intend to be more accurate in the future.
  2478. If you write a program which generates source code, such as the
  2479. 'bison' parser generator, you may want to adjust the preprocessor's
  2480. notion of the current file name and line number by hand. Parts of the
  2481. output from 'bison' are generated from scratch, other parts come from a
  2482. standard parser file. The rest are copied verbatim from 'bison''s
  2483. input. You would like compiler error messages and symbolic debuggers to
  2484. be able to refer to 'bison''s input file.
  2485. 'bison' or any such program can arrange this by writing '#line'
  2486. directives into the output file. '#line' is a directive that specifies
  2487. the original line number and source file name for subsequent input in
  2488. the current preprocessor input file. '#line' has three variants:
  2489. '#line LINENUM'
  2490. LINENUM is a non-negative decimal integer constant. It specifies
  2491. the line number which should be reported for the following line of
  2492. input. Subsequent lines are counted from LINENUM.
  2493. '#line LINENUM FILENAME'
  2494. LINENUM is the same as for the first form, and has the same effect.
  2495. In addition, FILENAME is a string constant. The following line and
  2496. all subsequent lines are reported to come from the file it
  2497. specifies, until something else happens to change that. FILENAME
  2498. is interpreted according to the normal rules for a string constant:
  2499. backslash escapes are interpreted. This is different from
  2500. '#include'.
  2501. '#line ANYTHING ELSE'
  2502. ANYTHING ELSE is checked for macro calls, which are expanded. The
  2503. result should match one of the above two forms.
  2504. '#line' directives alter the results of the '__FILE__' and '__LINE__'
  2505. predefined macros from that point on. *Note Standard Predefined
  2506. Macros::. They do not have any effect on '#include''s idea of the
  2507. directory containing the current file.
  2508. 
  2509. File: cpp.info, Node: Pragmas, Next: Other Directives, Prev: Line Control, Up: Top
  2510. 7 Pragmas
  2511. *********
  2512. The '#pragma' directive is the method specified by the C standard for
  2513. providing additional information to the compiler, beyond what is
  2514. conveyed in the language itself. The forms of this directive (commonly
  2515. known as "pragmas") specified by C standard are prefixed with 'STDC'. A
  2516. C compiler is free to attach any meaning it likes to other pragmas. All
  2517. GNU-defined, supported pragmas have been given a 'GCC' prefix.
  2518. C99 introduced the '_Pragma' operator. This feature addresses a
  2519. major problem with '#pragma': being a directive, it cannot be produced
  2520. as the result of macro expansion. '_Pragma' is an operator, much like
  2521. 'sizeof' or 'defined', and can be embedded in a macro.
  2522. Its syntax is '_Pragma (STRING-LITERAL)', where STRING-LITERAL can be
  2523. either a normal or wide-character string literal. It is destringized,
  2524. by replacing all '\\' with a single '\' and all '\"' with a '"'. The
  2525. result is then processed as if it had appeared as the right hand side of
  2526. a '#pragma' directive. For example,
  2527. _Pragma ("GCC dependency \"parse.y\"")
  2528. has the same effect as '#pragma GCC dependency "parse.y"'. The same
  2529. effect could be achieved using macros, for example
  2530. #define DO_PRAGMA(x) _Pragma (#x)
  2531. DO_PRAGMA (GCC dependency "parse.y")
  2532. The standard is unclear on where a '_Pragma' operator can appear.
  2533. The preprocessor does not accept it within a preprocessing conditional
  2534. directive like '#if'. To be safe, you are probably best keeping it out
  2535. of directives other than '#define', and putting it on a line of its own.
  2536. This manual documents the pragmas which are meaningful to the
  2537. preprocessor itself. Other pragmas are meaningful to the C or C++
  2538. compilers. They are documented in the GCC manual.
  2539. GCC plugins may provide their own pragmas.
  2540. '#pragma GCC dependency'
  2541. '#pragma GCC dependency' allows you to check the relative dates of
  2542. the current file and another file. If the other file is more
  2543. recent than the current file, a warning is issued. This is useful
  2544. if the current file is derived from the other file, and should be
  2545. regenerated. The other file is searched for using the normal
  2546. include search path. Optional trailing text can be used to give
  2547. more information in the warning message.
  2548. #pragma GCC dependency "parse.y"
  2549. #pragma GCC dependency "/usr/include/time.h" rerun fixincludes
  2550. '#pragma GCC poison'
  2551. Sometimes, there is an identifier that you want to remove
  2552. completely from your program, and make sure that it never creeps
  2553. back in. To enforce this, you can "poison" the identifier with
  2554. this pragma. '#pragma GCC poison' is followed by a list of
  2555. identifiers to poison. If any of those identifiers appears
  2556. anywhere in the source after the directive, it is a hard error.
  2557. For example,
  2558. #pragma GCC poison printf sprintf fprintf
  2559. sprintf(some_string, "hello");
  2560. will produce an error.
  2561. If a poisoned identifier appears as part of the expansion of a
  2562. macro which was defined before the identifier was poisoned, it will
  2563. _not_ cause an error. This lets you poison an identifier without
  2564. worrying about system headers defining macros that use it.
  2565. For example,
  2566. #define strrchr rindex
  2567. #pragma GCC poison rindex
  2568. strrchr(some_string, 'h');
  2569. will not produce an error.
  2570. '#pragma GCC system_header'
  2571. This pragma takes no arguments. It causes the rest of the code in
  2572. the current file to be treated as if it came from a system header.
  2573. *Note System Headers::.
  2574. '#pragma GCC warning'
  2575. '#pragma GCC error'
  2576. '#pragma GCC warning "message"' causes the preprocessor to issue a
  2577. warning diagnostic with the text 'message'. The message contained
  2578. in the pragma must be a single string literal. Similarly, '#pragma
  2579. GCC error "message"' issues an error message. Unlike the
  2580. '#warning' and '#error' directives, these pragmas can be embedded
  2581. in preprocessor macros using '_Pragma'.
  2582. 
  2583. File: cpp.info, Node: Other Directives, Next: Preprocessor Output, Prev: Pragmas, Up: Top
  2584. 8 Other Directives
  2585. ******************
  2586. The '#ident' directive takes one argument, a string constant. On some
  2587. systems, that string constant is copied into a special segment of the
  2588. object file. On other systems, the directive is ignored. The '#sccs'
  2589. directive is a synonym for '#ident'.
  2590. These directives are not part of the C standard, but they are not
  2591. official GNU extensions either. What historical information we have
  2592. been able to find, suggests they originated with System V.
  2593. The "null directive" consists of a '#' followed by a newline, with
  2594. only whitespace (including comments) in between. A null directive is
  2595. understood as a preprocessing directive but has no effect on the
  2596. preprocessor output. The primary significance of the existence of the
  2597. null directive is that an input line consisting of just a '#' will
  2598. produce no output, rather than a line of output containing just a '#'.
  2599. Supposedly some old C programs contain such lines.
  2600. 
  2601. File: cpp.info, Node: Preprocessor Output, Next: Traditional Mode, Prev: Other Directives, Up: Top
  2602. 9 Preprocessor Output
  2603. *********************
  2604. When the C preprocessor is used with the C, C++, or Objective-C
  2605. compilers, it is integrated into the compiler and communicates a stream
  2606. of binary tokens directly to the compiler's parser. However, it can
  2607. also be used in the more conventional standalone mode, where it produces
  2608. textual output.
  2609. The output from the C preprocessor looks much like the input, except
  2610. that all preprocessing directive lines have been replaced with blank
  2611. lines and all comments with spaces. Long runs of blank lines are
  2612. discarded.
  2613. The ISO standard specifies that it is implementation defined whether
  2614. a preprocessor preserves whitespace between tokens, or replaces it with
  2615. e.g. a single space. In GNU CPP, whitespace between tokens is collapsed
  2616. to become a single space, with the exception that the first token on a
  2617. non-directive line is preceded with sufficient spaces that it appears in
  2618. the same column in the preprocessed output that it appeared in the
  2619. original source file. This is so the output is easy to read. CPP does
  2620. not insert any whitespace where there was none in the original source,
  2621. except where necessary to prevent an accidental token paste.
  2622. Source file name and line number information is conveyed by lines of
  2623. the form
  2624. # LINENUM FILENAME FLAGS
  2625. These are called "linemarkers". They are inserted as needed into the
  2626. output (but never within a string or character constant). They mean
  2627. that the following line originated in file FILENAME at line LINENUM.
  2628. FILENAME will never contain any non-printing characters; they are
  2629. replaced with octal escape sequences.
  2630. After the file name comes zero or more flags, which are '1', '2',
  2631. '3', or '4'. If there are multiple flags, spaces separate them. Here
  2632. is what the flags mean:
  2633. '1'
  2634. This indicates the start of a new file.
  2635. '2'
  2636. This indicates returning to a file (after having included another
  2637. file).
  2638. '3'
  2639. This indicates that the following text comes from a system header
  2640. file, so certain warnings should be suppressed.
  2641. '4'
  2642. This indicates that the following text should be treated as being
  2643. wrapped in an implicit 'extern "C"' block.
  2644. As an extension, the preprocessor accepts linemarkers in
  2645. non-assembler input files. They are treated like the corresponding
  2646. '#line' directive, (*note Line Control::), except that trailing flags
  2647. are permitted, and are interpreted with the meanings described above.
  2648. If multiple flags are given, they must be in ascending order.
  2649. Some directives may be duplicated in the output of the preprocessor.
  2650. These are '#ident' (always), '#pragma' (only if the preprocessor does
  2651. not handle the pragma itself), and '#define' and '#undef' (with certain
  2652. debugging options). If this happens, the '#' of the directive will
  2653. always be in the first column, and there will be no space between the
  2654. '#' and the directive name. If macro expansion happens to generate
  2655. tokens which might be mistaken for a duplicated directive, a space will
  2656. be inserted between the '#' and the directive name.
  2657. 
  2658. File: cpp.info, Node: Traditional Mode, Next: Implementation Details, Prev: Preprocessor Output, Up: Top
  2659. 10 Traditional Mode
  2660. *******************
  2661. Traditional (pre-standard) C preprocessing is rather different from the
  2662. preprocessing specified by the standard. When the preprocessor is
  2663. invoked with the '-traditional-cpp' option, it attempts to emulate a
  2664. traditional preprocessor.
  2665. This mode is not useful for compiling C code with GCC, but is
  2666. intended for use with non-C preprocessing applications. Thus
  2667. traditional mode semantics are supported only when invoking the
  2668. preprocessor explicitly, and not in the compiler front ends.
  2669. The implementation does not correspond precisely to the behavior of
  2670. early pre-standard versions of GCC, nor to any true traditional
  2671. preprocessor. After all, inconsistencies among traditional
  2672. implementations were a major motivation for C standardization. However,
  2673. we intend that it should be compatible with true traditional
  2674. preprocessors in all ways that actually matter.
  2675. * Menu:
  2676. * Traditional lexical analysis::
  2677. * Traditional macros::
  2678. * Traditional miscellany::
  2679. * Traditional warnings::
  2680. 
  2681. File: cpp.info, Node: Traditional lexical analysis, Next: Traditional macros, Up: Traditional Mode
  2682. 10.1 Traditional lexical analysis
  2683. =================================
  2684. The traditional preprocessor does not decompose its input into tokens
  2685. the same way a standards-conforming preprocessor does. The input is
  2686. simply treated as a stream of text with minimal internal form.
  2687. This implementation does not treat trigraphs (*note trigraphs::)
  2688. specially since they were an invention of the standards committee. It
  2689. handles arbitrarily-positioned escaped newlines properly and splices the
  2690. lines as you would expect; many traditional preprocessors did not do
  2691. this.
  2692. The form of horizontal whitespace in the input file is preserved in
  2693. the output. In particular, hard tabs remain hard tabs. This can be
  2694. useful if, for example, you are preprocessing a Makefile.
  2695. Traditional CPP only recognizes C-style block comments, and treats
  2696. the '/*' sequence as introducing a comment only if it lies outside
  2697. quoted text. Quoted text is introduced by the usual single and double
  2698. quotes, and also by an initial '<' in a '#include' directive.
  2699. Traditionally, comments are completely removed and are not replaced
  2700. with a space. Since a traditional compiler does its own tokenization of
  2701. the output of the preprocessor, this means that comments can effectively
  2702. be used as token paste operators. However, comments behave like
  2703. separators for text handled by the preprocessor itself, since it doesn't
  2704. re-lex its input. For example, in
  2705. #if foo/**/bar
  2706. 'foo' and 'bar' are distinct identifiers and expanded separately if they
  2707. happen to be macros. In other words, this directive is equivalent to
  2708. #if foo bar
  2709. rather than
  2710. #if foobar
  2711. Generally speaking, in traditional mode an opening quote need not
  2712. have a matching closing quote. In particular, a macro may be defined
  2713. with replacement text that contains an unmatched quote. Of course, if
  2714. you attempt to compile preprocessed output containing an unmatched quote
  2715. you will get a syntax error.
  2716. However, all preprocessing directives other than '#define' require
  2717. matching quotes. For example:
  2718. #define m This macro's fine and has an unmatched quote
  2719. "/* This is not a comment. */
  2720. /* This is a comment. The following #include directive
  2721. is ill-formed. */
  2722. #include <stdio.h
  2723. Just as for the ISO preprocessor, what would be a closing quote can
  2724. be escaped with a backslash to prevent the quoted text from closing.
  2725. 
  2726. File: cpp.info, Node: Traditional macros, Next: Traditional miscellany, Prev: Traditional lexical analysis, Up: Traditional Mode
  2727. 10.2 Traditional macros
  2728. =======================
  2729. The major difference between traditional and ISO macros is that the
  2730. former expand to text rather than to a token sequence. CPP removes all
  2731. leading and trailing horizontal whitespace from a macro's replacement
  2732. text before storing it, but preserves the form of internal whitespace.
  2733. One consequence is that it is legitimate for the replacement text to
  2734. contain an unmatched quote (*note Traditional lexical analysis::). An
  2735. unclosed string or character constant continues into the text following
  2736. the macro call. Similarly, the text at the end of a macro's expansion
  2737. can run together with the text after the macro invocation to produce a
  2738. single token.
  2739. Normally comments are removed from the replacement text after the
  2740. macro is expanded, but if the '-CC' option is passed on the command-line
  2741. comments are preserved. (In fact, the current implementation removes
  2742. comments even before saving the macro replacement text, but it careful
  2743. to do it in such a way that the observed effect is identical even in the
  2744. function-like macro case.)
  2745. The ISO stringizing operator '#' and token paste operator '##' have
  2746. no special meaning. As explained later, an effect similar to these
  2747. operators can be obtained in a different way. Macro names that are
  2748. embedded in quotes, either from the main file or after macro
  2749. replacement, do not expand.
  2750. CPP replaces an unquoted object-like macro name with its replacement
  2751. text, and then rescans it for further macros to replace. Unlike
  2752. standard macro expansion, traditional macro expansion has no provision
  2753. to prevent recursion. If an object-like macro appears unquoted in its
  2754. replacement text, it will be replaced again during the rescan pass, and
  2755. so on _ad infinitum_. GCC detects when it is expanding recursive
  2756. macros, emits an error message, and continues after the offending macro
  2757. invocation.
  2758. #define PLUS +
  2759. #define INC(x) PLUS+x
  2760. INC(foo);
  2761. ==> ++foo;
  2762. Function-like macros are similar in form but quite different in
  2763. behavior to their ISO counterparts. Their arguments are contained
  2764. within parentheses, are comma-separated, and can cross physical lines.
  2765. Commas within nested parentheses are not treated as argument separators.
  2766. Similarly, a quote in an argument cannot be left unclosed; a following
  2767. comma or parenthesis that comes before the closing quote is treated like
  2768. any other character. There is no facility for handling variadic macros.
  2769. This implementation removes all comments from macro arguments, unless
  2770. the '-C' option is given. The form of all other horizontal whitespace
  2771. in arguments is preserved, including leading and trailing whitespace.
  2772. In particular
  2773. f( )
  2774. is treated as an invocation of the macro 'f' with a single argument
  2775. consisting of a single space. If you want to invoke a function-like
  2776. macro that takes no arguments, you must not leave any whitespace between
  2777. the parentheses.
  2778. If a macro argument crosses a new line, the new line is replaced with
  2779. a space when forming the argument. If the previous line contained an
  2780. unterminated quote, the following line inherits the quoted state.
  2781. Traditional preprocessors replace parameters in the replacement text
  2782. with their arguments regardless of whether the parameters are within
  2783. quotes or not. This provides a way to stringize arguments. For example
  2784. #define str(x) "x"
  2785. str(/* A comment */some text )
  2786. ==> "some text "
  2787. Note that the comment is removed, but that the trailing space is
  2788. preserved. Here is an example of using a comment to effect token
  2789. pasting.
  2790. #define suffix(x) foo_/**/x
  2791. suffix(bar)
  2792. ==> foo_bar
  2793. 
  2794. File: cpp.info, Node: Traditional miscellany, Next: Traditional warnings, Prev: Traditional macros, Up: Traditional Mode
  2795. 10.3 Traditional miscellany
  2796. ===========================
  2797. Here are some things to be aware of when using the traditional
  2798. preprocessor.
  2799. * Preprocessing directives are recognized only when their leading '#'
  2800. appears in the first column. There can be no whitespace between
  2801. the beginning of the line and the '#', but whitespace can follow
  2802. the '#'.
  2803. * A true traditional C preprocessor does not recognize '#error' or
  2804. '#pragma', and may not recognize '#elif'. CPP supports all the
  2805. directives in traditional mode that it supports in ISO mode,
  2806. including extensions, with the exception that the effects of
  2807. '#pragma GCC poison' are undefined.
  2808. * __STDC__ is not defined.
  2809. * If you use digraphs the behavior is undefined.
  2810. * If a line that looks like a directive appears within macro
  2811. arguments, the behavior is undefined.
  2812. 
  2813. File: cpp.info, Node: Traditional warnings, Prev: Traditional miscellany, Up: Traditional Mode
  2814. 10.4 Traditional warnings
  2815. =========================
  2816. You can request warnings about features that did not exist, or worked
  2817. differently, in traditional C with the '-Wtraditional' option. GCC does
  2818. not warn about features of ISO C which you must use when you are using a
  2819. conforming compiler, such as the '#' and '##' operators.
  2820. Presently '-Wtraditional' warns about:
  2821. * Macro parameters that appear within string literals in the macro
  2822. body. In traditional C macro replacement takes place within string
  2823. literals, but does not in ISO C.
  2824. * In traditional C, some preprocessor directives did not exist.
  2825. Traditional preprocessors would only consider a line to be a
  2826. directive if the '#' appeared in column 1 on the line. Therefore
  2827. '-Wtraditional' warns about directives that traditional C
  2828. understands but would ignore because the '#' does not appear as the
  2829. first character on the line. It also suggests you hide directives
  2830. like '#pragma' not understood by traditional C by indenting them.
  2831. Some traditional implementations would not recognize '#elif', so it
  2832. suggests avoiding it altogether.
  2833. * A function-like macro that appears without an argument list. In
  2834. some traditional preprocessors this was an error. In ISO C it
  2835. merely means that the macro is not expanded.
  2836. * The unary plus operator. This did not exist in traditional C.
  2837. * The 'U' and 'LL' integer constant suffixes, which were not
  2838. available in traditional C. (Traditional C does support the 'L'
  2839. suffix for simple long integer constants.) You are not warned
  2840. about uses of these suffixes in macros defined in system headers.
  2841. For instance, 'UINT_MAX' may well be defined as '4294967295U', but
  2842. you will not be warned if you use 'UINT_MAX'.
  2843. You can usually avoid the warning, and the related warning about
  2844. constants which are so large that they are unsigned, by writing the
  2845. integer constant in question in hexadecimal, with no U suffix.
  2846. Take care, though, because this gives the wrong result in exotic
  2847. cases.
  2848. 
  2849. File: cpp.info, Node: Implementation Details, Next: Invocation, Prev: Traditional Mode, Up: Top
  2850. 11 Implementation Details
  2851. *************************
  2852. Here we document details of how the preprocessor's implementation
  2853. affects its user-visible behavior. You should try to avoid undue
  2854. reliance on behavior described here, as it is possible that it will
  2855. change subtly in future implementations.
  2856. Also documented here are obsolete features still supported by CPP.
  2857. * Menu:
  2858. * Implementation-defined behavior::
  2859. * Implementation limits::
  2860. * Obsolete Features::
  2861. 
  2862. File: cpp.info, Node: Implementation-defined behavior, Next: Implementation limits, Up: Implementation Details
  2863. 11.1 Implementation-defined behavior
  2864. ====================================
  2865. This is how CPP behaves in all the cases which the C standard describes
  2866. as "implementation-defined". This term means that the implementation is
  2867. free to do what it likes, but must document its choice and stick to it.
  2868. * The mapping of physical source file multi-byte characters to the
  2869. execution character set.
  2870. The input character set can be specified using the
  2871. '-finput-charset' option, while the execution character set may be
  2872. controlled using the '-fexec-charset' and '-fwide-exec-charset'
  2873. options.
  2874. * Identifier characters.
  2875. The C and C++ standards allow identifiers to be composed of '_' and
  2876. the alphanumeric characters. C++ also allows universal character
  2877. names. C99 and later C standards permit both universal character
  2878. names and implementation-defined characters.
  2879. GCC allows the '$' character in identifiers as an extension for
  2880. most targets. This is true regardless of the 'std=' switch, since
  2881. this extension cannot conflict with standards-conforming programs.
  2882. When preprocessing assembler, however, dollars are not identifier
  2883. characters by default.
  2884. Currently the targets that by default do not permit '$' are AVR,
  2885. IP2K, MMIX, MIPS Irix 3, ARM aout, and PowerPC targets for the AIX
  2886. operating system.
  2887. You can override the default with '-fdollars-in-identifiers' or
  2888. 'fno-dollars-in-identifiers'. *Note fdollars-in-identifiers::.
  2889. * Non-empty sequences of whitespace characters.
  2890. In textual output, each whitespace sequence is collapsed to a
  2891. single space. For aesthetic reasons, the first token on each
  2892. non-directive line of output is preceded with sufficient spaces
  2893. that it appears in the same column as it did in the original source
  2894. file.
  2895. * The numeric value of character constants in preprocessor
  2896. expressions.
  2897. The preprocessor and compiler interpret character constants in the
  2898. same way; i.e. escape sequences such as '\a' are given the values
  2899. they would have on the target machine.
  2900. The compiler evaluates a multi-character character constant a
  2901. character at a time, shifting the previous value left by the number
  2902. of bits per target character, and then or-ing in the bit-pattern of
  2903. the new character truncated to the width of a target character.
  2904. The final bit-pattern is given type 'int', and is therefore signed,
  2905. regardless of whether single characters are signed or not. If
  2906. there are more characters in the constant than would fit in the
  2907. target 'int' the compiler issues a warning, and the excess leading
  2908. characters are ignored.
  2909. For example, ''ab'' for a target with an 8-bit 'char' would be
  2910. interpreted as
  2911. '(int) ((unsigned char) 'a' * 256 + (unsigned char) 'b')', and
  2912. ''\234a'' as
  2913. '(int) ((unsigned char) '\234' * 256 + (unsigned char) 'a')'.
  2914. * Source file inclusion.
  2915. For a discussion on how the preprocessor locates header files,
  2916. *note Include Operation::.
  2917. * Interpretation of the filename resulting from a macro-expanded
  2918. '#include' directive.
  2919. *Note Computed Includes::.
  2920. * Treatment of a '#pragma' directive that after macro-expansion
  2921. results in a standard pragma.
  2922. No macro expansion occurs on any '#pragma' directive line, so the
  2923. question does not arise.
  2924. Note that GCC does not yet implement any of the standard pragmas.
  2925. 
  2926. File: cpp.info, Node: Implementation limits, Next: Obsolete Features, Prev: Implementation-defined behavior, Up: Implementation Details
  2927. 11.2 Implementation limits
  2928. ==========================
  2929. CPP has a small number of internal limits. This section lists the
  2930. limits which the C standard requires to be no lower than some minimum,
  2931. and all the others known. It is intended that there should be as few
  2932. limits as possible. If you encounter an undocumented or inconvenient
  2933. limit, please report that as a bug. *Note Reporting Bugs: (gcc)Bugs.
  2934. Where we say something is limited "only by available memory", that
  2935. means that internal data structures impose no intrinsic limit, and space
  2936. is allocated with 'malloc' or equivalent. The actual limit will
  2937. therefore depend on many things, such as the size of other things
  2938. allocated by the compiler at the same time, the amount of memory
  2939. consumed by other processes on the same computer, etc.
  2940. * Nesting levels of '#include' files.
  2941. We impose an arbitrary limit of 200 levels, to avoid runaway
  2942. recursion. The standard requires at least 15 levels.
  2943. * Nesting levels of conditional inclusion.
  2944. The C standard mandates this be at least 63. CPP is limited only
  2945. by available memory.
  2946. * Levels of parenthesized expressions within a full expression.
  2947. The C standard requires this to be at least 63. In preprocessor
  2948. conditional expressions, it is limited only by available memory.
  2949. * Significant initial characters in an identifier or macro name.
  2950. The preprocessor treats all characters as significant. The C
  2951. standard requires only that the first 63 be significant.
  2952. * Number of macros simultaneously defined in a single translation
  2953. unit.
  2954. The standard requires at least 4095 be possible. CPP is limited
  2955. only by available memory.
  2956. * Number of parameters in a macro definition and arguments in a macro
  2957. call.
  2958. We allow 'USHRT_MAX', which is no smaller than 65,535. The minimum
  2959. required by the standard is 127.
  2960. * Number of characters on a logical source line.
  2961. The C standard requires a minimum of 4096 be permitted. CPP places
  2962. no limits on this, but you may get incorrect column numbers
  2963. reported in diagnostics for lines longer than 65,535 characters.
  2964. * Maximum size of a source file.
  2965. The standard does not specify any lower limit on the maximum size
  2966. of a source file. GNU cpp maps files into memory, so it is limited
  2967. by the available address space. This is generally at least two
  2968. gigabytes. Depending on the operating system, the size of physical
  2969. memory may or may not be a limitation.
  2970. 
  2971. File: cpp.info, Node: Obsolete Features, Prev: Implementation limits, Up: Implementation Details
  2972. 11.3 Obsolete Features
  2973. ======================
  2974. CPP has some features which are present mainly for compatibility with
  2975. older programs. We discourage their use in new code. In some cases, we
  2976. plan to remove the feature in a future version of GCC.
  2977. 11.3.1 Assertions
  2978. -----------------
  2979. "Assertions" are a deprecated alternative to macros in writing
  2980. conditionals to test what sort of computer or system the compiled
  2981. program will run on. Assertions are usually predefined, but you can
  2982. define them with preprocessing directives or command-line options.
  2983. Assertions were intended to provide a more systematic way to describe
  2984. the compiler's target system and we added them for compatibility with
  2985. existing compilers. In practice they are just as unpredictable as the
  2986. system-specific predefined macros. In addition, they are not part of
  2987. any standard, and only a few compilers support them. Therefore, the use
  2988. of assertions is *less* portable than the use of system-specific
  2989. predefined macros. We recommend you do not use them at all.
  2990. An assertion looks like this:
  2991. #PREDICATE (ANSWER)
  2992. PREDICATE must be a single identifier. ANSWER can be any sequence of
  2993. tokens; all characters are significant except for leading and trailing
  2994. whitespace, and differences in internal whitespace sequences are
  2995. ignored. (This is similar to the rules governing macro redefinition.)
  2996. Thus, '(x + y)' is different from '(x+y)' but equivalent to '( x + y )'.
  2997. Parentheses do not nest inside an answer.
  2998. To test an assertion, you write it in an '#if'. For example, this
  2999. conditional succeeds if either 'vax' or 'ns16000' has been asserted as
  3000. an answer for 'machine'.
  3001. #if #machine (vax) || #machine (ns16000)
  3002. You can test whether _any_ answer is asserted for a predicate by
  3003. omitting the answer in the conditional:
  3004. #if #machine
  3005. Assertions are made with the '#assert' directive. Its sole argument
  3006. is the assertion to make, without the leading '#' that identifies
  3007. assertions in conditionals.
  3008. #assert PREDICATE (ANSWER)
  3009. You may make several assertions with the same predicate and different
  3010. answers. Subsequent assertions do not override previous ones for the
  3011. same predicate. All the answers for any given predicate are
  3012. simultaneously true.
  3013. Assertions can be canceled with the '#unassert' directive. It has
  3014. the same syntax as '#assert'. In that form it cancels only the answer
  3015. which was specified on the '#unassert' line; other answers for that
  3016. predicate remain true. You can cancel an entire predicate by leaving
  3017. out the answer:
  3018. #unassert PREDICATE
  3019. In either form, if no such assertion has been made, '#unassert' has no
  3020. effect.
  3021. You can also make or cancel assertions using command-line options.
  3022. *Note Invocation::.
  3023. 
  3024. File: cpp.info, Node: Invocation, Next: Environment Variables, Prev: Implementation Details, Up: Top
  3025. 12 Invocation
  3026. *************
  3027. Most often when you use the C preprocessor you do not have to invoke it
  3028. explicitly: the C compiler does so automatically. However, the
  3029. preprocessor is sometimes useful on its own. You can invoke the
  3030. preprocessor either with the 'cpp' command, or via 'gcc -E'. In GCC,
  3031. the preprocessor is actually integrated with the compiler rather than a
  3032. separate program, and both of these commands invoke GCC and tell it to
  3033. stop after the preprocessing phase.
  3034. The 'cpp' options listed here are also accepted by 'gcc' and have the
  3035. same meaning. Likewise the 'cpp' command accepts all the usual 'gcc'
  3036. driver options, although those pertaining to compilation phases after
  3037. preprocessing are ignored.
  3038. Only options specific to preprocessing behavior are documented here.
  3039. Refer to the GCC manual for full documentation of other driver options.
  3040. The 'cpp' command expects two file names as arguments, INFILE and
  3041. OUTFILE. The preprocessor reads INFILE together with any other files it
  3042. specifies with '#include'. All the output generated by the combined
  3043. input files is written in OUTFILE.
  3044. Either INFILE or OUTFILE may be '-', which as INFILE means to read
  3045. from standard input and as OUTFILE means to write to standard output.
  3046. If either file is omitted, it means the same as if '-' had been
  3047. specified for that file. You can also use the '-o OUTFILE' option to
  3048. specify the output file.
  3049. Unless otherwise noted, or the option ends in '=', all options which
  3050. take an argument may have that argument appear either immediately after
  3051. the option, or with a space between option and argument: '-Ifoo' and '-I
  3052. foo' have the same effect.
  3053. Many options have multi-letter names; therefore multiple
  3054. single-letter options may _not_ be grouped: '-dM' is very different from
  3055. '-d -M'.
  3056. '-D NAME'
  3057. Predefine NAME as a macro, with definition '1'.
  3058. '-D NAME=DEFINITION'
  3059. The contents of DEFINITION are tokenized and processed as if they
  3060. appeared during translation phase three in a '#define' directive.
  3061. In particular, the definition is truncated by embedded newline
  3062. characters.
  3063. If you are invoking the preprocessor from a shell or shell-like
  3064. program you may need to use the shell's quoting syntax to protect
  3065. characters such as spaces that have a meaning in the shell syntax.
  3066. If you wish to define a function-like macro on the command line,
  3067. write its argument list with surrounding parentheses before the
  3068. equals sign (if any). Parentheses are meaningful to most shells,
  3069. so you should quote the option. With 'sh' and 'csh',
  3070. '-D'NAME(ARGS...)=DEFINITION'' works.
  3071. '-D' and '-U' options are processed in the order they are given on
  3072. the command line. All '-imacros FILE' and '-include FILE' options
  3073. are processed after all '-D' and '-U' options.
  3074. '-U NAME'
  3075. Cancel any previous definition of NAME, either built in or provided
  3076. with a '-D' option.
  3077. '-include FILE'
  3078. Process FILE as if '#include "file"' appeared as the first line of
  3079. the primary source file. However, the first directory searched for
  3080. FILE is the preprocessor's working directory _instead of_ the
  3081. directory containing the main source file. If not found there, it
  3082. is searched for in the remainder of the '#include "..."' search
  3083. chain as normal.
  3084. If multiple '-include' options are given, the files are included in
  3085. the order they appear on the command line.
  3086. '-imacros FILE'
  3087. Exactly like '-include', except that any output produced by
  3088. scanning FILE is thrown away. Macros it defines remain defined.
  3089. This allows you to acquire all the macros from a header without
  3090. also processing its declarations.
  3091. All files specified by '-imacros' are processed before all files
  3092. specified by '-include'.
  3093. '-undef'
  3094. Do not predefine any system-specific or GCC-specific macros. The
  3095. standard predefined macros remain defined. *Note Standard
  3096. Predefined Macros::.
  3097. '-pthread'
  3098. Define additional macros required for using the POSIX threads
  3099. library. You should use this option consistently for both
  3100. compilation and linking. This option is supported on GNU/Linux
  3101. targets, most other Unix derivatives, and also on x86 Cygwin and
  3102. MinGW targets.
  3103. '-M'
  3104. Instead of outputting the result of preprocessing, output a rule
  3105. suitable for 'make' describing the dependencies of the main source
  3106. file. The preprocessor outputs one 'make' rule containing the
  3107. object file name for that source file, a colon, and the names of
  3108. all the included files, including those coming from '-include' or
  3109. '-imacros' command-line options.
  3110. Unless specified explicitly (with '-MT' or '-MQ'), the object file
  3111. name consists of the name of the source file with any suffix
  3112. replaced with object file suffix and with any leading directory
  3113. parts removed. If there are many included files then the rule is
  3114. split into several lines using '\'-newline. The rule has no
  3115. commands.
  3116. This option does not suppress the preprocessor's debug output, such
  3117. as '-dM'. To avoid mixing such debug output with the dependency
  3118. rules you should explicitly specify the dependency output file with
  3119. '-MF', or use an environment variable like 'DEPENDENCIES_OUTPUT'
  3120. (*note Environment Variables::). Debug output is still sent to the
  3121. regular output stream as normal.
  3122. Passing '-M' to the driver implies '-E', and suppresses warnings
  3123. with an implicit '-w'.
  3124. '-MM'
  3125. Like '-M' but do not mention header files that are found in system
  3126. header directories, nor header files that are included, directly or
  3127. indirectly, from such a header.
  3128. This implies that the choice of angle brackets or double quotes in
  3129. an '#include' directive does not in itself determine whether that
  3130. header appears in '-MM' dependency output.
  3131. '-MF FILE'
  3132. When used with '-M' or '-MM', specifies a file to write the
  3133. dependencies to. If no '-MF' switch is given the preprocessor
  3134. sends the rules to the same place it would send preprocessed
  3135. output.
  3136. When used with the driver options '-MD' or '-MMD', '-MF' overrides
  3137. the default dependency output file.
  3138. '-MG'
  3139. In conjunction with an option such as '-M' requesting dependency
  3140. generation, '-MG' assumes missing header files are generated files
  3141. and adds them to the dependency list without raising an error. The
  3142. dependency filename is taken directly from the '#include' directive
  3143. without prepending any path. '-MG' also suppresses preprocessed
  3144. output, as a missing header file renders this useless.
  3145. This feature is used in automatic updating of makefiles.
  3146. '-MP'
  3147. This option instructs CPP to add a phony target for each dependency
  3148. other than the main file, causing each to depend on nothing. These
  3149. dummy rules work around errors 'make' gives if you remove header
  3150. files without updating the 'Makefile' to match.
  3151. This is typical output:
  3152. test.o: test.c test.h
  3153. test.h:
  3154. '-MT TARGET'
  3155. Change the target of the rule emitted by dependency generation. By
  3156. default CPP takes the name of the main input file, deletes any
  3157. directory components and any file suffix such as '.c', and appends
  3158. the platform's usual object suffix. The result is the target.
  3159. An '-MT' option sets the target to be exactly the string you
  3160. specify. If you want multiple targets, you can specify them as a
  3161. single argument to '-MT', or use multiple '-MT' options.
  3162. For example, '-MT '$(objpfx)foo.o'' might give
  3163. $(objpfx)foo.o: foo.c
  3164. '-MQ TARGET'
  3165. Same as '-MT', but it quotes any characters which are special to
  3166. Make. '-MQ '$(objpfx)foo.o'' gives
  3167. $$(objpfx)foo.o: foo.c
  3168. The default target is automatically quoted, as if it were given
  3169. with '-MQ'.
  3170. '-MD'
  3171. '-MD' is equivalent to '-M -MF FILE', except that '-E' is not
  3172. implied. The driver determines FILE based on whether an '-o'
  3173. option is given. If it is, the driver uses its argument but with a
  3174. suffix of '.d', otherwise it takes the name of the input file,
  3175. removes any directory components and suffix, and applies a '.d'
  3176. suffix.
  3177. If '-MD' is used in conjunction with '-E', any '-o' switch is
  3178. understood to specify the dependency output file (*note -MF:
  3179. dashMF.), but if used without '-E', each '-o' is understood to
  3180. specify a target object file.
  3181. Since '-E' is not implied, '-MD' can be used to generate a
  3182. dependency output file as a side-effect of the compilation process.
  3183. '-MMD'
  3184. Like '-MD' except mention only user header files, not system header
  3185. files.
  3186. '-fpreprocessed'
  3187. Indicate to the preprocessor that the input file has already been
  3188. preprocessed. This suppresses things like macro expansion,
  3189. trigraph conversion, escaped newline splicing, and processing of
  3190. most directives. The preprocessor still recognizes and removes
  3191. comments, so that you can pass a file preprocessed with '-C' to the
  3192. compiler without problems. In this mode the integrated
  3193. preprocessor is little more than a tokenizer for the front ends.
  3194. '-fpreprocessed' is implicit if the input file has one of the
  3195. extensions '.i', '.ii' or '.mi'. These are the extensions that GCC
  3196. uses for preprocessed files created by '-save-temps'.
  3197. '-fdirectives-only'
  3198. When preprocessing, handle directives, but do not expand macros.
  3199. The option's behavior depends on the '-E' and '-fpreprocessed'
  3200. options.
  3201. With '-E', preprocessing is limited to the handling of directives
  3202. such as '#define', '#ifdef', and '#error'. Other preprocessor
  3203. operations, such as macro expansion and trigraph conversion are not
  3204. performed. In addition, the '-dD' option is implicitly enabled.
  3205. With '-fpreprocessed', predefinition of command line and most
  3206. builtin macros is disabled. Macros such as '__LINE__', which are
  3207. contextually dependent, are handled normally. This enables
  3208. compilation of files previously preprocessed with '-E
  3209. -fdirectives-only'.
  3210. With both '-E' and '-fpreprocessed', the rules for '-fpreprocessed'
  3211. take precedence. This enables full preprocessing of files
  3212. previously preprocessed with '-E -fdirectives-only'.
  3213. '-fdollars-in-identifiers'
  3214. Accept '$' in identifiers. *Note Identifier characters::.
  3215. '-fextended-identifiers'
  3216. Accept universal character names in identifiers. This option is
  3217. enabled by default for C99 (and later C standard versions) and C++.
  3218. '-fno-canonical-system-headers'
  3219. When preprocessing, do not shorten system header paths with
  3220. canonicalization.
  3221. '-ftabstop=WIDTH'
  3222. Set the distance between tab stops. This helps the preprocessor
  3223. report correct column numbers in warnings or errors, even if tabs
  3224. appear on the line. If the value is less than 1 or greater than
  3225. 100, the option is ignored. The default is 8.
  3226. '-ftrack-macro-expansion[=LEVEL]'
  3227. Track locations of tokens across macro expansions. This allows the
  3228. compiler to emit diagnostic about the current macro expansion stack
  3229. when a compilation error occurs in a macro expansion. Using this
  3230. option makes the preprocessor and the compiler consume more memory.
  3231. The LEVEL parameter can be used to choose the level of precision of
  3232. token location tracking thus decreasing the memory consumption if
  3233. necessary. Value '0' of LEVEL de-activates this option. Value '1'
  3234. tracks tokens locations in a degraded mode for the sake of minimal
  3235. memory overhead. In this mode all tokens resulting from the
  3236. expansion of an argument of a function-like macro have the same
  3237. location. Value '2' tracks tokens locations completely. This
  3238. value is the most memory hungry. When this option is given no
  3239. argument, the default parameter value is '2'.
  3240. Note that '-ftrack-macro-expansion=2' is activated by default.
  3241. '-fexec-charset=CHARSET'
  3242. Set the execution character set, used for string and character
  3243. constants. The default is UTF-8. CHARSET can be any encoding
  3244. supported by the system's 'iconv' library routine.
  3245. '-fwide-exec-charset=CHARSET'
  3246. Set the wide execution character set, used for wide string and
  3247. character constants. The default is UTF-32 or UTF-16, whichever
  3248. corresponds to the width of 'wchar_t'. As with '-fexec-charset',
  3249. CHARSET can be any encoding supported by the system's 'iconv'
  3250. library routine; however, you will have problems with encodings
  3251. that do not fit exactly in 'wchar_t'.
  3252. '-finput-charset=CHARSET'
  3253. Set the input character set, used for translation from the
  3254. character set of the input file to the source character set used by
  3255. GCC. If the locale does not specify, or GCC cannot get this
  3256. information from the locale, the default is UTF-8. This can be
  3257. overridden by either the locale or this command-line option.
  3258. Currently the command-line option takes precedence if there's a
  3259. conflict. CHARSET can be any encoding supported by the system's
  3260. 'iconv' library routine.
  3261. '-fworking-directory'
  3262. Enable generation of linemarkers in the preprocessor output that
  3263. let the compiler know the current working directory at the time of
  3264. preprocessing. When this option is enabled, the preprocessor
  3265. emits, after the initial linemarker, a second linemarker with the
  3266. current working directory followed by two slashes. GCC uses this
  3267. directory, when it's present in the preprocessed input, as the
  3268. directory emitted as the current working directory in some
  3269. debugging information formats. This option is implicitly enabled
  3270. if debugging information is enabled, but this can be inhibited with
  3271. the negated form '-fno-working-directory'. If the '-P' flag is
  3272. present in the command line, this option has no effect, since no
  3273. '#line' directives are emitted whatsoever.
  3274. '-A PREDICATE=ANSWER'
  3275. Make an assertion with the predicate PREDICATE and answer ANSWER.
  3276. This form is preferred to the older form '-A PREDICATE(ANSWER)',
  3277. which is still supported, because it does not use shell special
  3278. characters. *Note Obsolete Features::.
  3279. '-A -PREDICATE=ANSWER'
  3280. Cancel an assertion with the predicate PREDICATE and answer ANSWER.
  3281. '-C'
  3282. Do not discard comments. All comments are passed through to the
  3283. output file, except for comments in processed directives, which are
  3284. deleted along with the directive.
  3285. You should be prepared for side effects when using '-C'; it causes
  3286. the preprocessor to treat comments as tokens in their own right.
  3287. For example, comments appearing at the start of what would be a
  3288. directive line have the effect of turning that line into an
  3289. ordinary source line, since the first token on the line is no
  3290. longer a '#'.
  3291. '-CC'
  3292. Do not discard comments, including during macro expansion. This is
  3293. like '-C', except that comments contained within macros are also
  3294. passed through to the output file where the macro is expanded.
  3295. In addition to the side-effects of the '-C' option, the '-CC'
  3296. option causes all C++-style comments inside a macro to be converted
  3297. to C-style comments. This is to prevent later use of that macro
  3298. from inadvertently commenting out the remainder of the source line.
  3299. The '-CC' option is generally used to support lint comments.
  3300. '-P'
  3301. Inhibit generation of linemarkers in the output from the
  3302. preprocessor. This might be useful when running the preprocessor
  3303. on something that is not C code, and will be sent to a program
  3304. which might be confused by the linemarkers. *Note Preprocessor
  3305. Output::.
  3306. '-traditional'
  3307. '-traditional-cpp'
  3308. Try to imitate the behavior of pre-standard C preprocessors, as
  3309. opposed to ISO C preprocessors. *Note Traditional Mode::.
  3310. Note that GCC does not otherwise attempt to emulate a pre-standard
  3311. C compiler, and these options are only supported with the '-E'
  3312. switch, or when invoking CPP explicitly.
  3313. '-trigraphs'
  3314. Support ISO C trigraphs. These are three-character sequences, all
  3315. starting with '??', that are defined by ISO C to stand for single
  3316. characters. For example, '??/' stands for '\', so ''??/n'' is a
  3317. character constant for a newline. *Note Initial processing::.
  3318. By default, GCC ignores trigraphs, but in standard-conforming modes
  3319. it converts them. See the '-std' and '-ansi' options.
  3320. '-remap'
  3321. Enable special code to work around file systems which only permit
  3322. very short file names, such as MS-DOS.
  3323. '-H'
  3324. Print the name of each header file used, in addition to other
  3325. normal activities. Each name is indented to show how deep in the
  3326. '#include' stack it is. Precompiled header files are also printed,
  3327. even if they are found to be invalid; an invalid precompiled header
  3328. file is printed with '...x' and a valid one with '...!' .
  3329. '-dLETTERS'
  3330. Says to make debugging dumps during compilation as specified by
  3331. LETTERS. The flags documented here are those relevant to the
  3332. preprocessor. Other LETTERS are interpreted by the compiler
  3333. proper, or reserved for future versions of GCC, and so are silently
  3334. ignored. If you specify LETTERS whose behavior conflicts, the
  3335. result is undefined.
  3336. '-dM'
  3337. Instead of the normal output, generate a list of '#define'
  3338. directives for all the macros defined during the execution of
  3339. the preprocessor, including predefined macros. This gives you
  3340. a way of finding out what is predefined in your version of the
  3341. preprocessor. Assuming you have no file 'foo.h', the command
  3342. touch foo.h; cpp -dM foo.h
  3343. shows all the predefined macros.
  3344. '-dD'
  3345. Like '-dM' except in two respects: it does _not_ include the
  3346. predefined macros, and it outputs _both_ the '#define'
  3347. directives and the result of preprocessing. Both kinds of
  3348. output go to the standard output file.
  3349. '-dN'
  3350. Like '-dD', but emit only the macro names, not their
  3351. expansions.
  3352. '-dI'
  3353. Output '#include' directives in addition to the result of
  3354. preprocessing.
  3355. '-dU'
  3356. Like '-dD' except that only macros that are expanded, or whose
  3357. definedness is tested in preprocessor directives, are output;
  3358. the output is delayed until the use or test of the macro; and
  3359. '#undef' directives are also output for macros tested but
  3360. undefined at the time.
  3361. '-fdebug-cpp'
  3362. This option is only useful for debugging GCC. When used from CPP or
  3363. with '-E', it dumps debugging information about location maps.
  3364. Every token in the output is preceded by the dump of the map its
  3365. location belongs to.
  3366. When used from GCC without '-E', this option has no effect.
  3367. '-I DIR'
  3368. '-iquote DIR'
  3369. '-isystem DIR'
  3370. '-idirafter DIR'
  3371. Add the directory DIR to the list of directories to be searched for
  3372. header files during preprocessing. *Note Search Path::. If DIR
  3373. begins with '=', then the '=' is replaced by the sysroot prefix;
  3374. see '--sysroot' and '-isysroot'.
  3375. Directories specified with '-iquote' apply only to the quote form
  3376. of the directive, '#include "FILE"'. Directories specified with
  3377. '-I', '-isystem', or '-idirafter' apply to lookup for both the
  3378. '#include "FILE"' and '#include <FILE>' directives.
  3379. You can specify any number or combination of these options on the
  3380. command line to search for header files in several directories.
  3381. The lookup order is as follows:
  3382. 1. For the quote form of the include directive, the directory of
  3383. the current file is searched first.
  3384. 2. For the quote form of the include directive, the directories
  3385. specified by '-iquote' options are searched in left-to-right
  3386. order, as they appear on the command line.
  3387. 3. Directories specified with '-I' options are scanned in
  3388. left-to-right order.
  3389. 4. Directories specified with '-isystem' options are scanned in
  3390. left-to-right order.
  3391. 5. Standard system directories are scanned.
  3392. 6. Directories specified with '-idirafter' options are scanned in
  3393. left-to-right order.
  3394. You can use '-I' to override a system header file, substituting
  3395. your own version, since these directories are searched before the
  3396. standard system header file directories. However, you should not
  3397. use this option to add directories that contain vendor-supplied
  3398. system header files; use '-isystem' for that.
  3399. The '-isystem' and '-idirafter' options also mark the directory as
  3400. a system directory, so that it gets the same special treatment that
  3401. is applied to the standard system directories. *Note System
  3402. Headers::.
  3403. If a standard system include directory, or a directory specified
  3404. with '-isystem', is also specified with '-I', the '-I' option is
  3405. ignored. The directory is still searched but as a system directory
  3406. at its normal position in the system include chain. This is to
  3407. ensure that GCC's procedure to fix buggy system headers and the
  3408. ordering for the '#include_next' directive are not inadvertently
  3409. changed. If you really need to change the search order for system
  3410. directories, use the '-nostdinc' and/or '-isystem' options. *Note
  3411. System Headers::.
  3412. '-I-'
  3413. Split the include path. This option has been deprecated. Please
  3414. use '-iquote' instead for '-I' directories before the '-I-' and
  3415. remove the '-I-' option.
  3416. Any directories specified with '-I' options before '-I-' are
  3417. searched only for headers requested with '#include "FILE"'; they
  3418. are not searched for '#include <FILE>'. If additional directories
  3419. are specified with '-I' options after the '-I-', those directories
  3420. are searched for all '#include' directives.
  3421. In addition, '-I-' inhibits the use of the directory of the current
  3422. file directory as the first search directory for '#include "FILE"'.
  3423. There is no way to override this effect of '-I-'. *Note Search
  3424. Path::.
  3425. '-iprefix PREFIX'
  3426. Specify PREFIX as the prefix for subsequent '-iwithprefix' options.
  3427. If the prefix represents a directory, you should include the final
  3428. '/'.
  3429. '-iwithprefix DIR'
  3430. '-iwithprefixbefore DIR'
  3431. Append DIR to the prefix specified previously with '-iprefix', and
  3432. add the resulting directory to the include search path.
  3433. '-iwithprefixbefore' puts it in the same place '-I' would;
  3434. '-iwithprefix' puts it where '-idirafter' would.
  3435. '-isysroot DIR'
  3436. This option is like the '--sysroot' option, but applies only to
  3437. header files (except for Darwin targets, where it applies to both
  3438. header files and libraries). See the '--sysroot' option for more
  3439. information.
  3440. '-imultilib DIR'
  3441. Use DIR as a subdirectory of the directory containing
  3442. target-specific C++ headers.
  3443. '-nostdinc'
  3444. Do not search the standard system directories for header files.
  3445. Only the directories explicitly specified with '-I', '-iquote',
  3446. '-isystem', and/or '-idirafter' options (and the directory of the
  3447. current file, if appropriate) are searched.
  3448. '-nostdinc++'
  3449. Do not search for header files in the C++-specific standard
  3450. directories, but do still search the other standard directories.
  3451. (This option is used when building the C++ library.)
  3452. '-Wcomment'
  3453. '-Wcomments'
  3454. Warn whenever a comment-start sequence '/*' appears in a '/*'
  3455. comment, or whenever a backslash-newline appears in a '//' comment.
  3456. This warning is enabled by '-Wall'.
  3457. '-Wtrigraphs'
  3458. Warn if any trigraphs are encountered that might change the meaning
  3459. of the program. Trigraphs within comments are not warned about,
  3460. except those that would form escaped newlines.
  3461. This option is implied by '-Wall'. If '-Wall' is not given, this
  3462. option is still enabled unless trigraphs are enabled. To get
  3463. trigraph conversion without warnings, but get the other '-Wall'
  3464. warnings, use '-trigraphs -Wall -Wno-trigraphs'.
  3465. '-Wundef'
  3466. Warn if an undefined identifier is evaluated in an '#if' directive.
  3467. Such identifiers are replaced with zero.
  3468. '-Wexpansion-to-defined'
  3469. Warn whenever 'defined' is encountered in the expansion of a macro
  3470. (including the case where the macro is expanded by an '#if'
  3471. directive). Such usage is not portable. This warning is also
  3472. enabled by '-Wpedantic' and '-Wextra'.
  3473. '-Wunused-macros'
  3474. Warn about macros defined in the main file that are unused. A
  3475. macro is "used" if it is expanded or tested for existence at least
  3476. once. The preprocessor also warns if the macro has not been used
  3477. at the time it is redefined or undefined.
  3478. Built-in macros, macros defined on the command line, and macros
  3479. defined in include files are not warned about.
  3480. _Note:_ If a macro is actually used, but only used in skipped
  3481. conditional blocks, then the preprocessor reports it as unused. To
  3482. avoid the warning in such a case, you might improve the scope of
  3483. the macro's definition by, for example, moving it into the first
  3484. skipped block. Alternatively, you could provide a dummy use with
  3485. something like:
  3486. #if defined the_macro_causing_the_warning
  3487. #endif
  3488. '-Wno-endif-labels'
  3489. Do not warn whenever an '#else' or an '#endif' are followed by
  3490. text. This sometimes happens in older programs with code of the
  3491. form
  3492. #if FOO
  3493. ...
  3494. #else FOO
  3495. ...
  3496. #endif FOO
  3497. The second and third 'FOO' should be in comments. This warning is
  3498. on by default.
  3499. 
  3500. File: cpp.info, Node: Environment Variables, Next: GNU Free Documentation License, Prev: Invocation, Up: Top
  3501. 13 Environment Variables
  3502. ************************
  3503. This section describes the environment variables that affect how CPP
  3504. operates. You can use them to specify directories or prefixes to use
  3505. when searching for include files, or to control dependency output.
  3506. Note that you can also specify places to search using options such as
  3507. '-I', and control dependency output with options like '-M' (*note
  3508. Invocation::). These take precedence over environment variables, which
  3509. in turn take precedence over the configuration of GCC.
  3510. 'CPATH'
  3511. 'C_INCLUDE_PATH'
  3512. 'CPLUS_INCLUDE_PATH'
  3513. 'OBJC_INCLUDE_PATH'
  3514. Each variable's value is a list of directories separated by a
  3515. special character, much like 'PATH', in which to look for header
  3516. files. The special character, 'PATH_SEPARATOR', is
  3517. target-dependent and determined at GCC build time. For Microsoft
  3518. Windows-based targets it is a semicolon, and for almost all other
  3519. targets it is a colon.
  3520. 'CPATH' specifies a list of directories to be searched as if
  3521. specified with '-I', but after any paths given with '-I' options on
  3522. the command line. This environment variable is used regardless of
  3523. which language is being preprocessed.
  3524. The remaining environment variables apply only when preprocessing
  3525. the particular language indicated. Each specifies a list of
  3526. directories to be searched as if specified with '-isystem', but
  3527. after any paths given with '-isystem' options on the command line.
  3528. In all these variables, an empty element instructs the compiler to
  3529. search its current working directory. Empty elements can appear at
  3530. the beginning or end of a path. For instance, if the value of
  3531. 'CPATH' is ':/special/include', that has the same effect as
  3532. '-I. -I/special/include'.
  3533. See also *note Search Path::.
  3534. 'DEPENDENCIES_OUTPUT'
  3535. If this variable is set, its value specifies how to output
  3536. dependencies for Make based on the non-system header files
  3537. processed by the compiler. System header files are ignored in the
  3538. dependency output.
  3539. The value of 'DEPENDENCIES_OUTPUT' can be just a file name, in
  3540. which case the Make rules are written to that file, guessing the
  3541. target name from the source file name. Or the value can have the
  3542. form 'FILE TARGET', in which case the rules are written to file
  3543. FILE using TARGET as the target name.
  3544. In other words, this environment variable is equivalent to
  3545. combining the options '-MM' and '-MF' (*note Invocation::), with an
  3546. optional '-MT' switch too.
  3547. 'SUNPRO_DEPENDENCIES'
  3548. This variable is the same as 'DEPENDENCIES_OUTPUT' (see above),
  3549. except that system header files are not ignored, so it implies '-M'
  3550. rather than '-MM'. However, the dependence on the main input file
  3551. is omitted. *Note Invocation::.
  3552. 'SOURCE_DATE_EPOCH'
  3553. If this variable is set, its value specifies a UNIX timestamp to be
  3554. used in replacement of the current date and time in the '__DATE__'
  3555. and '__TIME__' macros, so that the embedded timestamps become
  3556. reproducible.
  3557. The value of 'SOURCE_DATE_EPOCH' must be a UNIX timestamp, defined
  3558. as the number of seconds (excluding leap seconds) since 01 Jan 1970
  3559. 00:00:00 represented in ASCII; identical to the output of ''date
  3560. +%s'' on GNU/Linux and other systems that support the '%s'
  3561. extension in the 'date' command.
  3562. The value should be a known timestamp such as the last modification
  3563. time of the source or package and it should be set by the build
  3564. process.
  3565. 
  3566. File: cpp.info, Node: GNU Free Documentation License, Next: Index of Directives, Prev: Environment Variables, Up: Top
  3567. GNU Free Documentation License
  3568. ******************************
  3569. Version 1.3, 3 November 2008
  3570. Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
  3571. <http://fsf.org/>
  3572. Everyone is permitted to copy and distribute verbatim copies
  3573. of this license document, but changing it is not allowed.
  3574. 0. PREAMBLE
  3575. The purpose of this License is to make a manual, textbook, or other
  3576. functional and useful document "free" in the sense of freedom: to
  3577. assure everyone the effective freedom to copy and redistribute it,
  3578. with or without modifying it, either commercially or
  3579. noncommercially. Secondarily, this License preserves for the
  3580. author and publisher a way to get credit for their work, while not
  3581. being considered responsible for modifications made by others.
  3582. This License is a kind of "copyleft", which means that derivative
  3583. works of the document must themselves be free in the same sense.
  3584. It complements the GNU General Public License, which is a copyleft
  3585. license designed for free software.
  3586. We have designed this License in order to use it for manuals for
  3587. free software, because free software needs free documentation: a
  3588. free program should come with manuals providing the same freedoms
  3589. that the software does. But this License is not limited to
  3590. software manuals; it can be used for any textual work, regardless
  3591. of subject matter or whether it is published as a printed book. We
  3592. recommend this License principally for works whose purpose is
  3593. instruction or reference.
  3594. 1. APPLICABILITY AND DEFINITIONS
  3595. This License applies to any manual or other work, in any medium,
  3596. that contains a notice placed by the copyright holder saying it can
  3597. be distributed under the terms of this License. Such a notice
  3598. grants a world-wide, royalty-free license, unlimited in duration,
  3599. to use that work under the conditions stated herein. The
  3600. "Document", below, refers to any such manual or work. Any member
  3601. of the public is a licensee, and is addressed as "you". You accept
  3602. the license if you copy, modify or distribute the work in a way
  3603. requiring permission under copyright law.
  3604. A "Modified Version" of the Document means any work containing the
  3605. Document or a portion of it, either copied verbatim, or with
  3606. modifications and/or translated into another language.
  3607. A "Secondary Section" is a named appendix or a front-matter section
  3608. of the Document that deals exclusively with the relationship of the
  3609. publishers or authors of the Document to the Document's overall
  3610. subject (or to related matters) and contains nothing that could
  3611. fall directly within that overall subject. (Thus, if the Document
  3612. is in part a textbook of mathematics, a Secondary Section may not
  3613. explain any mathematics.) The relationship could be a matter of
  3614. historical connection with the subject or with related matters, or
  3615. of legal, commercial, philosophical, ethical or political position
  3616. regarding them.
  3617. The "Invariant Sections" are certain Secondary Sections whose
  3618. titles are designated, as being those of Invariant Sections, in the
  3619. notice that says that the Document is released under this License.
  3620. If a section does not fit the above definition of Secondary then it
  3621. is not allowed to be designated as Invariant. The Document may
  3622. contain zero Invariant Sections. If the Document does not identify
  3623. any Invariant Sections then there are none.
  3624. The "Cover Texts" are certain short passages of text that are
  3625. listed, as Front-Cover Texts or Back-Cover Texts, in the notice
  3626. that says that the Document is released under this License. A
  3627. Front-Cover Text may be at most 5 words, and a Back-Cover Text may
  3628. be at most 25 words.
  3629. A "Transparent" copy of the Document means a machine-readable copy,
  3630. represented in a format whose specification is available to the
  3631. general public, that is suitable for revising the document
  3632. straightforwardly with generic text editors or (for images composed
  3633. of pixels) generic paint programs or (for drawings) some widely
  3634. available drawing editor, and that is suitable for input to text
  3635. formatters or for automatic translation to a variety of formats
  3636. suitable for input to text formatters. A copy made in an otherwise
  3637. Transparent file format whose markup, or absence of markup, has
  3638. been arranged to thwart or discourage subsequent modification by
  3639. readers is not Transparent. An image format is not Transparent if
  3640. used for any substantial amount of text. A copy that is not
  3641. "Transparent" is called "Opaque".
  3642. Examples of suitable formats for Transparent copies include plain
  3643. ASCII without markup, Texinfo input format, LaTeX input format,
  3644. SGML or XML using a publicly available DTD, and standard-conforming
  3645. simple HTML, PostScript or PDF designed for human modification.
  3646. Examples of transparent image formats include PNG, XCF and JPG.
  3647. Opaque formats include proprietary formats that can be read and
  3648. edited only by proprietary word processors, SGML or XML for which
  3649. the DTD and/or processing tools are not generally available, and
  3650. the machine-generated HTML, PostScript or PDF produced by some word
  3651. processors for output purposes only.
  3652. The "Title Page" means, for a printed book, the title page itself,
  3653. plus such following pages as are needed to hold, legibly, the
  3654. material this License requires to appear in the title page. For
  3655. works in formats which do not have any title page as such, "Title
  3656. Page" means the text near the most prominent appearance of the
  3657. work's title, preceding the beginning of the body of the text.
  3658. The "publisher" means any person or entity that distributes copies
  3659. of the Document to the public.
  3660. A section "Entitled XYZ" means a named subunit of the Document
  3661. whose title either is precisely XYZ or contains XYZ in parentheses
  3662. following text that translates XYZ in another language. (Here XYZ
  3663. stands for a specific section name mentioned below, such as
  3664. "Acknowledgements", "Dedications", "Endorsements", or "History".)
  3665. To "Preserve the Title" of such a section when you modify the
  3666. Document means that it remains a section "Entitled XYZ" according
  3667. to this definition.
  3668. The Document may include Warranty Disclaimers next to the notice
  3669. which states that this License applies to the Document. These
  3670. Warranty Disclaimers are considered to be included by reference in
  3671. this License, but only as regards disclaiming warranties: any other
  3672. implication that these Warranty Disclaimers may have is void and
  3673. has no effect on the meaning of this License.
  3674. 2. VERBATIM COPYING
  3675. You may copy and distribute the Document in any medium, either
  3676. commercially or noncommercially, provided that this License, the
  3677. copyright notices, and the license notice saying this License
  3678. applies to the Document are reproduced in all copies, and that you
  3679. add no other conditions whatsoever to those of this License. You
  3680. may not use technical measures to obstruct or control the reading
  3681. or further copying of the copies you make or distribute. However,
  3682. you may accept compensation in exchange for copies. If you
  3683. distribute a large enough number of copies you must also follow the
  3684. conditions in section 3.
  3685. You may also lend copies, under the same conditions stated above,
  3686. and you may publicly display copies.
  3687. 3. COPYING IN QUANTITY
  3688. If you publish printed copies (or copies in media that commonly
  3689. have printed covers) of the Document, numbering more than 100, and
  3690. the Document's license notice requires Cover Texts, you must
  3691. enclose the copies in covers that carry, clearly and legibly, all
  3692. these Cover Texts: Front-Cover Texts on the front cover, and
  3693. Back-Cover Texts on the back cover. Both covers must also clearly
  3694. and legibly identify you as the publisher of these copies. The
  3695. front cover must present the full title with all words of the title
  3696. equally prominent and visible. You may add other material on the
  3697. covers in addition. Copying with changes limited to the covers, as
  3698. long as they preserve the title of the Document and satisfy these
  3699. conditions, can be treated as verbatim copying in other respects.
  3700. If the required texts for either cover are too voluminous to fit
  3701. legibly, you should put the first ones listed (as many as fit
  3702. reasonably) on the actual cover, and continue the rest onto
  3703. adjacent pages.
  3704. If you publish or distribute Opaque copies of the Document
  3705. numbering more than 100, you must either include a machine-readable
  3706. Transparent copy along with each Opaque copy, or state in or with
  3707. each Opaque copy a computer-network location from which the general
  3708. network-using public has access to download using public-standard
  3709. network protocols a complete Transparent copy of the Document, free
  3710. of added material. If you use the latter option, you must take
  3711. reasonably prudent steps, when you begin distribution of Opaque
  3712. copies in quantity, to ensure that this Transparent copy will
  3713. remain thus accessible at the stated location until at least one
  3714. year after the last time you distribute an Opaque copy (directly or
  3715. through your agents or retailers) of that edition to the public.
  3716. It is requested, but not required, that you contact the authors of
  3717. the Document well before redistributing any large number of copies,
  3718. to give them a chance to provide you with an updated version of the
  3719. Document.
  3720. 4. MODIFICATIONS
  3721. You may copy and distribute a Modified Version of the Document
  3722. under the conditions of sections 2 and 3 above, provided that you
  3723. release the Modified Version under precisely this License, with the
  3724. Modified Version filling the role of the Document, thus licensing
  3725. distribution and modification of the Modified Version to whoever
  3726. possesses a copy of it. In addition, you must do these things in
  3727. the Modified Version:
  3728. A. Use in the Title Page (and on the covers, if any) a title
  3729. distinct from that of the Document, and from those of previous
  3730. versions (which should, if there were any, be listed in the
  3731. History section of the Document). You may use the same title
  3732. as a previous version if the original publisher of that
  3733. version gives permission.
  3734. B. List on the Title Page, as authors, one or more persons or
  3735. entities responsible for authorship of the modifications in
  3736. the Modified Version, together with at least five of the
  3737. principal authors of the Document (all of its principal
  3738. authors, if it has fewer than five), unless they release you
  3739. from this requirement.
  3740. C. State on the Title page the name of the publisher of the
  3741. Modified Version, as the publisher.
  3742. D. Preserve all the copyright notices of the Document.
  3743. E. Add an appropriate copyright notice for your modifications
  3744. adjacent to the other copyright notices.
  3745. F. Include, immediately after the copyright notices, a license
  3746. notice giving the public permission to use the Modified
  3747. Version under the terms of this License, in the form shown in
  3748. the Addendum below.
  3749. G. Preserve in that license notice the full lists of Invariant
  3750. Sections and required Cover Texts given in the Document's
  3751. license notice.
  3752. H. Include an unaltered copy of this License.
  3753. I. Preserve the section Entitled "History", Preserve its Title,
  3754. and add to it an item stating at least the title, year, new
  3755. authors, and publisher of the Modified Version as given on the
  3756. Title Page. If there is no section Entitled "History" in the
  3757. Document, create one stating the title, year, authors, and
  3758. publisher of the Document as given on its Title Page, then add
  3759. an item describing the Modified Version as stated in the
  3760. previous sentence.
  3761. J. Preserve the network location, if any, given in the Document
  3762. for public access to a Transparent copy of the Document, and
  3763. likewise the network locations given in the Document for
  3764. previous versions it was based on. These may be placed in the
  3765. "History" section. You may omit a network location for a work
  3766. that was published at least four years before the Document
  3767. itself, or if the original publisher of the version it refers
  3768. to gives permission.
  3769. K. For any section Entitled "Acknowledgements" or "Dedications",
  3770. Preserve the Title of the section, and preserve in the section
  3771. all the substance and tone of each of the contributor
  3772. acknowledgements and/or dedications given therein.
  3773. L. Preserve all the Invariant Sections of the Document, unaltered
  3774. in their text and in their titles. Section numbers or the
  3775. equivalent are not considered part of the section titles.
  3776. M. Delete any section Entitled "Endorsements". Such a section
  3777. may not be included in the Modified Version.
  3778. N. Do not retitle any existing section to be Entitled
  3779. "Endorsements" or to conflict in title with any Invariant
  3780. Section.
  3781. O. Preserve any Warranty Disclaimers.
  3782. If the Modified Version includes new front-matter sections or
  3783. appendices that qualify as Secondary Sections and contain no
  3784. material copied from the Document, you may at your option designate
  3785. some or all of these sections as invariant. To do this, add their
  3786. titles to the list of Invariant Sections in the Modified Version's
  3787. license notice. These titles must be distinct from any other
  3788. section titles.
  3789. You may add a section Entitled "Endorsements", provided it contains
  3790. nothing but endorsements of your Modified Version by various
  3791. parties--for example, statements of peer review or that the text
  3792. has been approved by an organization as the authoritative
  3793. definition of a standard.
  3794. You may add a passage of up to five words as a Front-Cover Text,
  3795. and a passage of up to 25 words as a Back-Cover Text, to the end of
  3796. the list of Cover Texts in the Modified Version. Only one passage
  3797. of Front-Cover Text and one of Back-Cover Text may be added by (or
  3798. through arrangements made by) any one entity. If the Document
  3799. already includes a cover text for the same cover, previously added
  3800. by you or by arrangement made by the same entity you are acting on
  3801. behalf of, you may not add another; but you may replace the old
  3802. one, on explicit permission from the previous publisher that added
  3803. the old one.
  3804. The author(s) and publisher(s) of the Document do not by this
  3805. License give permission to use their names for publicity for or to
  3806. assert or imply endorsement of any Modified Version.
  3807. 5. COMBINING DOCUMENTS
  3808. You may combine the Document with other documents released under
  3809. this License, under the terms defined in section 4 above for
  3810. modified versions, provided that you include in the combination all
  3811. of the Invariant Sections of all of the original documents,
  3812. unmodified, and list them all as Invariant Sections of your
  3813. combined work in its license notice, and that you preserve all
  3814. their Warranty Disclaimers.
  3815. The combined work need only contain one copy of this License, and
  3816. multiple identical Invariant Sections may be replaced with a single
  3817. copy. If there are multiple Invariant Sections with the same name
  3818. but different contents, make the title of each such section unique
  3819. by adding at the end of it, in parentheses, the name of the
  3820. original author or publisher of that section if known, or else a
  3821. unique number. Make the same adjustment to the section titles in
  3822. the list of Invariant Sections in the license notice of the
  3823. combined work.
  3824. In the combination, you must combine any sections Entitled
  3825. "History" in the various original documents, forming one section
  3826. Entitled "History"; likewise combine any sections Entitled
  3827. "Acknowledgements", and any sections Entitled "Dedications". You
  3828. must delete all sections Entitled "Endorsements."
  3829. 6. COLLECTIONS OF DOCUMENTS
  3830. You may make a collection consisting of the Document and other
  3831. documents released under this License, and replace the individual
  3832. copies of this License in the various documents with a single copy
  3833. that is included in the collection, provided that you follow the
  3834. rules of this License for verbatim copying of each of the documents
  3835. in all other respects.
  3836. You may extract a single document from such a collection, and
  3837. distribute it individually under this License, provided you insert
  3838. a copy of this License into the extracted document, and follow this
  3839. License in all other respects regarding verbatim copying of that
  3840. document.
  3841. 7. AGGREGATION WITH INDEPENDENT WORKS
  3842. A compilation of the Document or its derivatives with other
  3843. separate and independent documents or works, in or on a volume of a
  3844. storage or distribution medium, is called an "aggregate" if the
  3845. copyright resulting from the compilation is not used to limit the
  3846. legal rights of the compilation's users beyond what the individual
  3847. works permit. When the Document is included in an aggregate, this
  3848. License does not apply to the other works in the aggregate which
  3849. are not themselves derivative works of the Document.
  3850. If the Cover Text requirement of section 3 is applicable to these
  3851. copies of the Document, then if the Document is less than one half
  3852. of the entire aggregate, the Document's Cover Texts may be placed
  3853. on covers that bracket the Document within the aggregate, or the
  3854. electronic equivalent of covers if the Document is in electronic
  3855. form. Otherwise they must appear on printed covers that bracket
  3856. the whole aggregate.
  3857. 8. TRANSLATION
  3858. Translation is considered a kind of modification, so you may
  3859. distribute translations of the Document under the terms of section
  3860. 4. Replacing Invariant Sections with translations requires special
  3861. permission from their copyright holders, but you may include
  3862. translations of some or all Invariant Sections in addition to the
  3863. original versions of these Invariant Sections. You may include a
  3864. translation of this License, and all the license notices in the
  3865. Document, and any Warranty Disclaimers, provided that you also
  3866. include the original English version of this License and the
  3867. original versions of those notices and disclaimers. In case of a
  3868. disagreement between the translation and the original version of
  3869. this License or a notice or disclaimer, the original version will
  3870. prevail.
  3871. If a section in the Document is Entitled "Acknowledgements",
  3872. "Dedications", or "History", the requirement (section 4) to
  3873. Preserve its Title (section 1) will typically require changing the
  3874. actual title.
  3875. 9. TERMINATION
  3876. You may not copy, modify, sublicense, or distribute the Document
  3877. except as expressly provided under this License. Any attempt
  3878. otherwise to copy, modify, sublicense, or distribute it is void,
  3879. and will automatically terminate your rights under this License.
  3880. However, if you cease all violation of this License, then your
  3881. license from a particular copyright holder is reinstated (a)
  3882. provisionally, unless and until the copyright holder explicitly and
  3883. finally terminates your license, and (b) permanently, if the
  3884. copyright holder fails to notify you of the violation by some
  3885. reasonable means prior to 60 days after the cessation.
  3886. Moreover, your license from a particular copyright holder is
  3887. reinstated permanently if the copyright holder notifies you of the
  3888. violation by some reasonable means, this is the first time you have
  3889. received notice of violation of this License (for any work) from
  3890. that copyright holder, and you cure the violation prior to 30 days
  3891. after your receipt of the notice.
  3892. Termination of your rights under this section does not terminate
  3893. the licenses of parties who have received copies or rights from you
  3894. under this License. If your rights have been terminated and not
  3895. permanently reinstated, receipt of a copy of some or all of the
  3896. same material does not give you any rights to use it.
  3897. 10. FUTURE REVISIONS OF THIS LICENSE
  3898. The Free Software Foundation may publish new, revised versions of
  3899. the GNU Free Documentation License from time to time. Such new
  3900. versions will be similar in spirit to the present version, but may
  3901. differ in detail to address new problems or concerns. See
  3902. <http://www.gnu.org/copyleft/>.
  3903. Each version of the License is given a distinguishing version
  3904. number. If the Document specifies that a particular numbered
  3905. version of this License "or any later version" applies to it, you
  3906. have the option of following the terms and conditions either of
  3907. that specified version or of any later version that has been
  3908. published (not as a draft) by the Free Software Foundation. If the
  3909. Document does not specify a version number of this License, you may
  3910. choose any version ever published (not as a draft) by the Free
  3911. Software Foundation. If the Document specifies that a proxy can
  3912. decide which future versions of this License can be used, that
  3913. proxy's public statement of acceptance of a version permanently
  3914. authorizes you to choose that version for the Document.
  3915. 11. RELICENSING
  3916. "Massive Multiauthor Collaboration Site" (or "MMC Site") means any
  3917. World Wide Web server that publishes copyrightable works and also
  3918. provides prominent facilities for anybody to edit those works. A
  3919. public wiki that anybody can edit is an example of such a server.
  3920. A "Massive Multiauthor Collaboration" (or "MMC") contained in the
  3921. site means any set of copyrightable works thus published on the MMC
  3922. site.
  3923. "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
  3924. license published by Creative Commons Corporation, a not-for-profit
  3925. corporation with a principal place of business in San Francisco,
  3926. California, as well as future copyleft versions of that license
  3927. published by that same organization.
  3928. "Incorporate" means to publish or republish a Document, in whole or
  3929. in part, as part of another Document.
  3930. An MMC is "eligible for relicensing" if it is licensed under this
  3931. License, and if all works that were first published under this
  3932. License somewhere other than this MMC, and subsequently
  3933. incorporated in whole or in part into the MMC, (1) had no cover
  3934. texts or invariant sections, and (2) were thus incorporated prior
  3935. to November 1, 2008.
  3936. The operator of an MMC Site may republish an MMC contained in the
  3937. site under CC-BY-SA on the same site at any time before August 1,
  3938. 2009, provided the MMC is eligible for relicensing.
  3939. ADDENDUM: How to use this License for your documents
  3940. ====================================================
  3941. To use this License in a document you have written, include a copy of
  3942. the License in the document and put the following copyright and license
  3943. notices just after the title page:
  3944. Copyright (C) YEAR YOUR NAME.
  3945. Permission is granted to copy, distribute and/or modify this document
  3946. under the terms of the GNU Free Documentation License, Version 1.3
  3947. or any later version published by the Free Software Foundation;
  3948. with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
  3949. Texts. A copy of the license is included in the section entitled ``GNU
  3950. Free Documentation License''.
  3951. If you have Invariant Sections, Front-Cover Texts and Back-Cover
  3952. Texts, replace the "with...Texts." line with this:
  3953. with the Invariant Sections being LIST THEIR TITLES, with
  3954. the Front-Cover Texts being LIST, and with the Back-Cover Texts
  3955. being LIST.
  3956. If you have Invariant Sections without Cover Texts, or some other
  3957. combination of the three, merge those two alternatives to suit the
  3958. situation.
  3959. If your document contains nontrivial examples of program code, we
  3960. recommend releasing these examples in parallel under your choice of free
  3961. software license, such as the GNU General Public License, to permit
  3962. their use in free software.
  3963. 
  3964. File: cpp.info, Node: Index of Directives, Next: Option Index, Prev: GNU Free Documentation License, Up: Top
  3965. Index of Directives
  3966. *******************
  3967. �[index�]
  3968. * Menu:
  3969. * #assert: Obsolete Features. (line 48)
  3970. * #define: Object-like Macros. (line 11)
  3971. * #elif: Elif. (line 6)
  3972. * #else: Else. (line 6)
  3973. * #endif: Ifdef. (line 6)
  3974. * #error: Diagnostics. (line 6)
  3975. * #ident: Other Directives. (line 6)
  3976. * #if: Conditional Syntax. (line 6)
  3977. * #ifdef: Ifdef. (line 6)
  3978. * #ifndef: Ifdef. (line 40)
  3979. * #import: Alternatives to Wrapper #ifndef.
  3980. (line 11)
  3981. * #include: Include Syntax. (line 6)
  3982. * #include_next: Wrapper Headers. (line 6)
  3983. * #line: Line Control. (line 20)
  3984. * #pragma GCC dependency: Pragmas. (line 43)
  3985. * #pragma GCC error: Pragmas. (line 88)
  3986. * #pragma GCC poison: Pragmas. (line 55)
  3987. * #pragma GCC system_header: System Headers. (line 25)
  3988. * #pragma GCC system_header <1>: Pragmas. (line 82)
  3989. * #pragma GCC warning: Pragmas. (line 87)
  3990. * #sccs: Other Directives. (line 6)
  3991. * #unassert: Obsolete Features. (line 59)
  3992. * #undef: Undefining and Redefining Macros.
  3993. (line 6)
  3994. * #warning: Diagnostics. (line 27)
  3995. 
  3996. File: cpp.info, Node: Option Index, Next: Concept Index, Prev: Index of Directives, Up: Top
  3997. Option Index
  3998. ************
  3999. CPP's command-line options and environment variables are indexed here
  4000. without any initial '-' or '--'.
  4001. �[index�]
  4002. * Menu:
  4003. * A: Invocation. (line 318)
  4004. * C: Invocation. (line 327)
  4005. * CC: Invocation. (line 339)
  4006. * CPATH: Environment Variables.
  4007. (line 15)
  4008. * CPLUS_INCLUDE_PATH: Environment Variables.
  4009. (line 17)
  4010. * C_INCLUDE_PATH: Environment Variables.
  4011. (line 16)
  4012. * D: Invocation. (line 44)
  4013. * d: Invocation. (line 388)
  4014. * dD: Invocation. (line 407)
  4015. * DEPENDENCIES_OUTPUT: Environment Variables.
  4016. (line 44)
  4017. * dI: Invocation. (line 417)
  4018. * dM: Invocation. (line 396)
  4019. * dN: Invocation. (line 413)
  4020. * dU: Invocation. (line 421)
  4021. * fdebug-cpp: Invocation. (line 428)
  4022. * fdirectives-only: Invocation. (line 226)
  4023. * fdollars-in-identifiers: Invocation. (line 247)
  4024. * fexec-charset: Invocation. (line 281)
  4025. * fextended-identifiers: Invocation. (line 250)
  4026. * finput-charset: Invocation. (line 294)
  4027. * fno-canonical-system-headers: Invocation. (line 254)
  4028. * fno-working-directory: Invocation. (line 304)
  4029. * fpreprocessed: Invocation. (line 213)
  4030. * ftabstop: Invocation. (line 258)
  4031. * ftrack-macro-expansion: Invocation. (line 264)
  4032. * fwide-exec-charset: Invocation. (line 286)
  4033. * fworking-directory: Invocation. (line 304)
  4034. * H: Invocation. (line 381)
  4035. * I: Invocation. (line 439)
  4036. * I-: Invocation. (line 493)
  4037. * idirafter: Invocation. (line 439)
  4038. * imacros: Invocation. (line 82)
  4039. * imultilib: Invocation. (line 527)
  4040. * include: Invocation. (line 71)
  4041. * iprefix: Invocation. (line 509)
  4042. * iquote: Invocation. (line 439)
  4043. * isysroot: Invocation. (line 521)
  4044. * isystem: Invocation. (line 439)
  4045. * iwithprefix: Invocation. (line 515)
  4046. * iwithprefixbefore: Invocation. (line 515)
  4047. * M: Invocation. (line 103)
  4048. * MD: Invocation. (line 193)
  4049. * MF: Invocation. (line 137)
  4050. * MG: Invocation. (line 146)
  4051. * MM: Invocation. (line 128)
  4052. * MMD: Invocation. (line 209)
  4053. * MP: Invocation. (line 156)
  4054. * MQ: Invocation. (line 183)
  4055. * MT: Invocation. (line 168)
  4056. * nostdinc: Invocation. (line 531)
  4057. * nostdinc++: Invocation. (line 537)
  4058. * OBJC_INCLUDE_PATH: Environment Variables.
  4059. (line 18)
  4060. * P: Invocation. (line 351)
  4061. * pthread: Invocation. (line 96)
  4062. * remap: Invocation. (line 377)
  4063. * SOURCE_DATE_EPOCH: Environment Variables.
  4064. (line 66)
  4065. * SUNPRO_DEPENDENCIES: Environment Variables.
  4066. (line 60)
  4067. * traditional: Invocation. (line 359)
  4068. * traditional-cpp: Invocation. (line 359)
  4069. * trigraphs: Invocation. (line 368)
  4070. * U: Invocation. (line 67)
  4071. * undef: Invocation. (line 91)
  4072. * Wcomment: Invocation. (line 543)
  4073. * Wcomments: Invocation. (line 543)
  4074. * Wendif-labels: Invocation. (line 587)
  4075. * Wexpansion-to-defined: Invocation. (line 562)
  4076. * Wno-endif-labels: Invocation. (line 587)
  4077. * Wno-undef: Invocation. (line 558)
  4078. * Wtrigraphs: Invocation. (line 548)
  4079. * Wundef: Invocation. (line 558)
  4080. * Wunused-macros: Invocation. (line 568)
  4081. 
  4082. File: cpp.info, Node: Concept Index, Prev: Option Index, Up: Top
  4083. Concept Index
  4084. *************
  4085. �[index�]
  4086. * Menu:
  4087. * '#' operator: Stringizing. (line 6)
  4088. * '##' operator: Concatenation. (line 6)
  4089. * '_Pragma': Pragmas. (line 13)
  4090. * alternative tokens: Tokenization. (line 101)
  4091. * arguments: Macro Arguments. (line 6)
  4092. * arguments in macro definitions: Macro Arguments. (line 6)
  4093. * assertions: Obsolete Features. (line 13)
  4094. * assertions, canceling: Obsolete Features. (line 59)
  4095. * backslash-newline: Initial processing. (line 61)
  4096. * block comments: Initial processing. (line 77)
  4097. * C language, traditional: Invocation. (line 357)
  4098. * C++ named operators: C++ Named Operators. (line 6)
  4099. * character constants: Tokenization. (line 82)
  4100. * character set, execution: Invocation. (line 281)
  4101. * character set, input: Invocation. (line 294)
  4102. * character set, wide execution: Invocation. (line 286)
  4103. * command line: Invocation. (line 6)
  4104. * commenting out code: Deleted Code. (line 6)
  4105. * comments: Initial processing. (line 77)
  4106. * common predefined macros: Common Predefined Macros.
  4107. (line 6)
  4108. * computed includes: Computed Includes. (line 6)
  4109. * concatenation: Concatenation. (line 6)
  4110. * conditional group: Ifdef. (line 14)
  4111. * conditionals: Conditionals. (line 6)
  4112. * continued lines: Initial processing. (line 61)
  4113. * controlling macro: Once-Only Headers. (line 35)
  4114. * 'defined': Defined. (line 6)
  4115. * dependencies for make as output: Environment Variables.
  4116. (line 45)
  4117. * dependencies for make as output <1>: Environment Variables.
  4118. (line 61)
  4119. * dependencies, 'make': Invocation. (line 103)
  4120. * diagnostic: Diagnostics. (line 6)
  4121. * digraphs: Tokenization. (line 101)
  4122. * directive line: The preprocessing language.
  4123. (line 6)
  4124. * directive name: The preprocessing language.
  4125. (line 6)
  4126. * directives: The preprocessing language.
  4127. (line 6)
  4128. * empty macro arguments: Macro Arguments. (line 66)
  4129. * environment variables: Environment Variables.
  4130. (line 6)
  4131. * expansion of arguments: Argument Prescan. (line 6)
  4132. * FDL, GNU Free Documentation License: GNU Free Documentation License.
  4133. (line 6)
  4134. * function-like macros: Function-like Macros.
  4135. (line 6)
  4136. * grouping options: Invocation. (line 38)
  4137. * guard macro: Once-Only Headers. (line 35)
  4138. * header file: Header Files. (line 6)
  4139. * header file names: Tokenization. (line 82)
  4140. * identifiers: Tokenization. (line 33)
  4141. * implementation limits: Implementation limits.
  4142. (line 6)
  4143. * implementation-defined behavior: Implementation-defined behavior.
  4144. (line 6)
  4145. * including just once: Once-Only Headers. (line 6)
  4146. * invocation: Invocation. (line 6)
  4147. * 'iso646.h': C++ Named Operators. (line 6)
  4148. * line comments: Initial processing. (line 77)
  4149. * line control: Line Control. (line 6)
  4150. * line endings: Initial processing. (line 14)
  4151. * linemarkers: Preprocessor Output. (line 27)
  4152. * macro argument expansion: Argument Prescan. (line 6)
  4153. * macro arguments and directives: Directives Within Macro Arguments.
  4154. (line 6)
  4155. * macros in include: Computed Includes. (line 6)
  4156. * macros with arguments: Macro Arguments. (line 6)
  4157. * macros with variable arguments: Variadic Macros. (line 6)
  4158. * 'make': Invocation. (line 103)
  4159. * manifest constants: Object-like Macros. (line 6)
  4160. * named operators: C++ Named Operators. (line 6)
  4161. * newlines in macro arguments: Newlines in Arguments.
  4162. (line 6)
  4163. * null directive: Other Directives. (line 15)
  4164. * numbers: Tokenization. (line 59)
  4165. * object-like macro: Object-like Macros. (line 6)
  4166. * options: Invocation. (line 43)
  4167. * options, grouping: Invocation. (line 38)
  4168. * other tokens: Tokenization. (line 115)
  4169. * output format: Preprocessor Output. (line 12)
  4170. * overriding a header file: Wrapper Headers. (line 6)
  4171. * parentheses in macro bodies: Operator Precedence Problems.
  4172. (line 6)
  4173. * pitfalls of macros: Macro Pitfalls. (line 6)
  4174. * predefined macros: Predefined Macros. (line 6)
  4175. * predefined macros, system-specific: System-specific Predefined Macros.
  4176. (line 6)
  4177. * predicates: Obsolete Features. (line 26)
  4178. * preprocessing directives: The preprocessing language.
  4179. (line 6)
  4180. * preprocessing numbers: Tokenization. (line 59)
  4181. * preprocessing tokens: Tokenization. (line 6)
  4182. * prescan of macro arguments: Argument Prescan. (line 6)
  4183. * problems with macros: Macro Pitfalls. (line 6)
  4184. * punctuators: Tokenization. (line 101)
  4185. * redefining macros: Undefining and Redefining Macros.
  4186. (line 6)
  4187. * repeated inclusion: Once-Only Headers. (line 6)
  4188. * reporting errors: Diagnostics. (line 6)
  4189. * reporting warnings: Diagnostics. (line 6)
  4190. * reserved namespace: System-specific Predefined Macros.
  4191. (line 6)
  4192. * self-reference: Self-Referential Macros.
  4193. (line 6)
  4194. * semicolons (after macro calls): Swallowing the Semicolon.
  4195. (line 6)
  4196. * side effects (in macro arguments): Duplication of Side Effects.
  4197. (line 6)
  4198. * standard predefined macros.: Standard Predefined Macros.
  4199. (line 6)
  4200. * string constants: Tokenization. (line 82)
  4201. * string literals: Tokenization. (line 82)
  4202. * stringizing: Stringizing. (line 6)
  4203. * symbolic constants: Object-like Macros. (line 6)
  4204. * system header files: Header Files. (line 13)
  4205. * system header files <1>: System Headers. (line 6)
  4206. * system-specific predefined macros: System-specific Predefined Macros.
  4207. (line 6)
  4208. * testing predicates: Obsolete Features. (line 37)
  4209. * token concatenation: Concatenation. (line 6)
  4210. * token pasting: Concatenation. (line 6)
  4211. * tokens: Tokenization. (line 6)
  4212. * traditional C language: Invocation. (line 357)
  4213. * trigraphs: Initial processing. (line 32)
  4214. * undefining macros: Undefining and Redefining Macros.
  4215. (line 6)
  4216. * unsafe macros: Duplication of Side Effects.
  4217. (line 6)
  4218. * variable number of arguments: Variadic Macros. (line 6)
  4219. * variadic macros: Variadic Macros. (line 6)
  4220. * wrapper '#ifndef': Once-Only Headers. (line 6)
  4221. * wrapper headers: Wrapper Headers. (line 6)
  4222. 
  4223. Tag Table:
  4224. Node: Top945
  4225. Node: Overview3506
  4226. Node: Character sets6340
  4227. Ref: Character sets-Footnote-18495
  4228. Node: Initial processing8676
  4229. Ref: trigraphs10235
  4230. Node: Tokenization14435
  4231. Ref: Tokenization-Footnote-121336
  4232. Node: The preprocessing language21447
  4233. Node: Header Files24326
  4234. Node: Include Syntax26242
  4235. Node: Include Operation27879
  4236. Node: Search Path29727
  4237. Node: Once-Only Headers31949
  4238. Node: Alternatives to Wrapper #ifndef33608
  4239. Node: Computed Includes35350
  4240. Node: Wrapper Headers38508
  4241. Node: System Headers40931
  4242. Node: Macros42396
  4243. Node: Object-like Macros43533
  4244. Node: Function-like Macros47123
  4245. Node: Macro Arguments48739
  4246. Node: Stringizing52878
  4247. Node: Concatenation56039
  4248. Node: Variadic Macros59136
  4249. Node: Predefined Macros63127
  4250. Node: Standard Predefined Macros63715
  4251. Node: Common Predefined Macros69716
  4252. Node: System-specific Predefined Macros90138
  4253. Node: C++ Named Operators92161
  4254. Node: Undefining and Redefining Macros93125
  4255. Node: Directives Within Macro Arguments95223
  4256. Node: Macro Pitfalls96164
  4257. Node: Misnesting96697
  4258. Node: Operator Precedence Problems97809
  4259. Node: Swallowing the Semicolon99675
  4260. Node: Duplication of Side Effects101698
  4261. Node: Self-Referential Macros103881
  4262. Node: Argument Prescan106290
  4263. Node: Newlines in Arguments110041
  4264. Node: Conditionals110992
  4265. Node: Conditional Uses112688
  4266. Node: Conditional Syntax114046
  4267. Node: Ifdef114366
  4268. Node: If117523
  4269. Node: Defined119827
  4270. Node: Else121220
  4271. Node: Elif121790
  4272. Node: Deleted Code123079
  4273. Node: Diagnostics124326
  4274. Node: Line Control125875
  4275. Node: Pragmas128153
  4276. Node: Other Directives132286
  4277. Node: Preprocessor Output133336
  4278. Node: Traditional Mode136489
  4279. Node: Traditional lexical analysis137626
  4280. Node: Traditional macros140129
  4281. Node: Traditional miscellany143926
  4282. Node: Traditional warnings144922
  4283. Node: Implementation Details147119
  4284. Node: Implementation-defined behavior147682
  4285. Ref: Identifier characters148432
  4286. Node: Implementation limits151299
  4287. Node: Obsolete Features153972
  4288. Node: Invocation156816
  4289. Ref: dashMF162851
  4290. Ref: fdollars-in-identifiers167361
  4291. Ref: Wtrigraphs180852
  4292. Node: Environment Variables182907
  4293. Node: GNU Free Documentation License186600
  4294. Node: Index of Directives211745
  4295. Node: Option Index213825
  4296. Node: Concept Index219708
  4297. 
  4298. End Tag Table