cpp.info 229 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414
  1. This is cpp.info, produced by makeinfo version 6.7 from cpp.texi.
  2. Copyright (C) 1987-2018 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-2018 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', '-std=c11' or '-std=c17'
  148. options, depending on which version of the standard you want. To get
  149. all the 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 historically it was less
  1171. flexible: you had to supply at least one argument after the format
  1172. string. In standard C, you could not omit the comma separating the
  1173. named argument from the variable arguments. (Note that this restriction
  1174. has been lifted in C++2a, and never existed in GNU C; see below.)
  1175. Furthermore, if you left the variable argument empty, you would have
  1176. gotten a syntax error, because there would have been an extra comma
  1177. after the format string.
  1178. eprintf("success!\n", );
  1179. ==> fprintf(stderr, "success!\n", );
  1180. This has been fixed in C++2a, and GNU CPP also has a pair of
  1181. extensions which deal with this problem.
  1182. First, in GNU CPP, and in C++ beginning in C++2a, you are allowed to
  1183. leave the variable argument out entirely:
  1184. eprintf ("success!\n")
  1185. ==> fprintf(stderr, "success!\n", );
  1186. Second, C++2a introduces the '__VA_OPT__' function macro. This macro
  1187. may only appear in the definition of a variadic macro. If the variable
  1188. argument has any tokens, then a '__VA_OPT__' invocation expands to its
  1189. argument; but if the variable argument does not have any tokens, the
  1190. '__VA_OPT__' expands to nothing:
  1191. #define eprintf(format, ...) \
  1192. fprintf (stderr, format __VA_OPT__(,) __VA_ARGS__)
  1193. '__VA_OPT__' is also available in GNU C and GNU C++.
  1194. Historically, GNU CPP has also had another extension to handle the
  1195. trailing comma: the '##' token paste operator has a special meaning when
  1196. placed between a comma and a variable argument. Despite the
  1197. introduction of '__VA_OPT__', this extension remains supported in GNU
  1198. CPP, for backward compatibility. If you write
  1199. #define eprintf(format, ...) fprintf (stderr, format, ##__VA_ARGS__)
  1200. and the variable argument is left out when the 'eprintf' macro is used,
  1201. then the comma before the '##' will be deleted. This does _not_ happen
  1202. if you pass an empty argument, nor does it happen if the token preceding
  1203. '##' is anything other than a comma.
  1204. eprintf ("success!\n")
  1205. ==> fprintf(stderr, "success!\n");
  1206. The above explanation is ambiguous about the case where the only macro
  1207. parameter is a variable arguments parameter, as it is meaningless to try
  1208. to distinguish whether no argument at all is an empty argument or a
  1209. missing argument. CPP retains the comma when conforming to a specific C
  1210. standard. Otherwise the comma is dropped as an extension to the
  1211. standard.
  1212. The C standard mandates that the only place the identifier
  1213. '__VA_ARGS__' can appear is in the replacement list of a variadic macro.
  1214. It may not be used as a macro name, macro argument name, or within a
  1215. different type of macro. It may also be forbidden in open text; the
  1216. standard is ambiguous. We recommend you avoid using it except for its
  1217. defined purpose.
  1218. Likewise, C++ forbids '__VA_OPT__' anywhere outside the replacement
  1219. list of a variadic macro.
  1220. Variadic macros became a standard part of the C language with C99.
  1221. GNU CPP previously supported them with a named variable argument
  1222. ('args...', not '...' and '__VA_ARGS__'), which is still supported for
  1223. backward compatibility.
  1224. 
  1225. File: cpp.info, Node: Predefined Macros, Next: Undefining and Redefining Macros, Prev: Variadic Macros, Up: Macros
  1226. 3.7 Predefined Macros
  1227. =====================
  1228. Several object-like macros are predefined; you use them without
  1229. supplying their definitions. They fall into three classes: standard,
  1230. common, and system-specific.
  1231. In C++, there is a fourth category, the named operators. They act
  1232. like predefined macros, but you cannot undefine them.
  1233. * Menu:
  1234. * Standard Predefined Macros::
  1235. * Common Predefined Macros::
  1236. * System-specific Predefined Macros::
  1237. * C++ Named Operators::
  1238. 
  1239. File: cpp.info, Node: Standard Predefined Macros, Next: Common Predefined Macros, Up: Predefined Macros
  1240. 3.7.1 Standard Predefined Macros
  1241. --------------------------------
  1242. The standard predefined macros are specified by the relevant language
  1243. standards, so they are available with all compilers that implement those
  1244. standards. Older compilers may not provide all of them. Their names
  1245. all start with double underscores.
  1246. '__FILE__'
  1247. This macro expands to the name of the current input file, in the
  1248. form of a C string constant. This is the path by which the
  1249. preprocessor opened the file, not the short name specified in
  1250. '#include' or as the input file name argument. For example,
  1251. '"/usr/local/include/myheader.h"' is a possible expansion of this
  1252. macro.
  1253. '__LINE__'
  1254. This macro expands to the current input line number, in the form of
  1255. a decimal integer constant. While we call it a predefined macro,
  1256. it's a pretty strange macro, since its "definition" changes with
  1257. each new line of source code.
  1258. '__FILE__' and '__LINE__' are useful in generating an error message
  1259. to report an inconsistency detected by the program; the message can
  1260. state the source line at which the inconsistency was detected. For
  1261. example,
  1262. fprintf (stderr, "Internal error: "
  1263. "negative string length "
  1264. "%d at %s, line %d.",
  1265. length, __FILE__, __LINE__);
  1266. An '#include' directive changes the expansions of '__FILE__' and
  1267. '__LINE__' to correspond to the included file. At the end of that file,
  1268. when processing resumes on the input file that contained the '#include'
  1269. directive, the expansions of '__FILE__' and '__LINE__' revert to the
  1270. values they had before the '#include' (but '__LINE__' is then
  1271. incremented by one as processing moves to the line after the
  1272. '#include').
  1273. A '#line' directive changes '__LINE__', and may change '__FILE__' as
  1274. well. *Note Line Control::.
  1275. C99 introduced '__func__', and GCC has provided '__FUNCTION__' for a
  1276. long time. Both of these are strings containing the name of the current
  1277. function (there are slight semantic differences; see the GCC manual).
  1278. Neither of them is a macro; the preprocessor does not know the name of
  1279. the current function. They tend to be useful in conjunction with
  1280. '__FILE__' and '__LINE__', though.
  1281. '__DATE__'
  1282. This macro expands to a string constant that describes the date on
  1283. which the preprocessor is being run. The string constant contains
  1284. eleven characters and looks like '"Feb 12 1996"'. If the day of
  1285. the month is less than 10, it is padded with a space on the left.
  1286. If GCC cannot determine the current date, it will emit a warning
  1287. message (once per compilation) and '__DATE__' will expand to
  1288. '"??? ?? ????"'.
  1289. '__TIME__'
  1290. This macro expands to a string constant that describes the time at
  1291. which the preprocessor is being run. The string constant contains
  1292. eight characters and looks like '"23:59:01"'.
  1293. If GCC cannot determine the current time, it will emit a warning
  1294. message (once per compilation) and '__TIME__' will expand to
  1295. '"??:??:??"'.
  1296. '__STDC__'
  1297. In normal operation, this macro expands to the constant 1, to
  1298. signify that this compiler conforms to ISO Standard C. If GNU CPP
  1299. is used with a compiler other than GCC, this is not necessarily
  1300. true; however, the preprocessor always conforms to the standard
  1301. unless the '-traditional-cpp' option is used.
  1302. This macro is not defined if the '-traditional-cpp' option is used.
  1303. On some hosts, the system compiler uses a different convention,
  1304. where '__STDC__' is normally 0, but is 1 if the user specifies
  1305. strict conformance to the C Standard. CPP follows the host
  1306. convention when processing system header files, but when processing
  1307. user files '__STDC__' is always 1. This has been reported to cause
  1308. problems; for instance, some versions of Solaris provide X Windows
  1309. headers that expect '__STDC__' to be either undefined or 1. *Note
  1310. Invocation::.
  1311. '__STDC_VERSION__'
  1312. This macro expands to the C Standard's version number, a long
  1313. integer constant of the form 'YYYYMML' where YYYY and MM are the
  1314. year and month of the Standard version. This signifies which
  1315. version of the C Standard the compiler conforms to. Like
  1316. '__STDC__', this is not necessarily accurate for the entire
  1317. implementation, unless GNU CPP is being used with GCC.
  1318. The value '199409L' signifies the 1989 C standard as amended in
  1319. 1994, which is the current default; the value '199901L' signifies
  1320. the 1999 revision of the C standard; the value '201112L' signifies
  1321. the 2011 revision of the C standard; the value '201710L' signifies
  1322. the 2017 revision of the C standard (which is otherwise identical
  1323. to the 2011 version apart from correction of defects).
  1324. This macro is not defined if the '-traditional-cpp' option is used,
  1325. nor when compiling C++ or Objective-C.
  1326. '__STDC_HOSTED__'
  1327. This macro is defined, with value 1, if the compiler's target is a
  1328. "hosted environment". A hosted environment has the complete
  1329. facilities of the standard C library available.
  1330. '__cplusplus'
  1331. This macro is defined when the C++ compiler is in use. You can use
  1332. '__cplusplus' to test whether a header is compiled by a C compiler
  1333. or a C++ compiler. This macro is similar to '__STDC_VERSION__', in
  1334. that it expands to a version number. Depending on the language
  1335. standard selected, the value of the macro is '199711L' for the 1998
  1336. C++ standard, '201103L' for the 2011 C++ standard, '201402L' for
  1337. the 2014 C++ standard, '201703L' for the 2017 C++ standard, or an
  1338. unspecified value strictly larger than '201703L' for the
  1339. experimental languages enabled by '-std=c++2a' and '-std=gnu++2a'.
  1340. '__OBJC__'
  1341. This macro is defined, with value 1, when the Objective-C compiler
  1342. is in use. You can use '__OBJC__' to test whether a header is
  1343. compiled by a C compiler or an Objective-C compiler.
  1344. '__ASSEMBLER__'
  1345. This macro is defined with value 1 when preprocessing assembly
  1346. language.
  1347. 
  1348. File: cpp.info, Node: Common Predefined Macros, Next: System-specific Predefined Macros, Prev: Standard Predefined Macros, Up: Predefined Macros
  1349. 3.7.2 Common Predefined Macros
  1350. ------------------------------
  1351. The common predefined macros are GNU C extensions. They are available
  1352. with the same meanings regardless of the machine or operating system on
  1353. which you are using GNU C or GNU Fortran. Their names all start with
  1354. double underscores.
  1355. '__COUNTER__'
  1356. This macro expands to sequential integral values starting from 0.
  1357. In conjunction with the '##' operator, this provides a convenient
  1358. means to generate unique identifiers. Care must be taken to ensure
  1359. that '__COUNTER__' is not expanded prior to inclusion of
  1360. precompiled headers which use it. Otherwise, the precompiled
  1361. headers will not be used.
  1362. '__GFORTRAN__'
  1363. The GNU Fortran compiler defines this.
  1364. '__GNUC__'
  1365. '__GNUC_MINOR__'
  1366. '__GNUC_PATCHLEVEL__'
  1367. These macros are defined by all GNU compilers that use the C
  1368. preprocessor: C, C++, Objective-C and Fortran. Their values are
  1369. the major version, minor version, and patch level of the compiler,
  1370. as integer constants. For example, GCC version X.Y.Z defines
  1371. '__GNUC__' to X, '__GNUC_MINOR__' to Y, and '__GNUC_PATCHLEVEL__'
  1372. to Z. These macros are also defined if you invoke the preprocessor
  1373. directly.
  1374. If all you need to know is whether or not your program is being
  1375. compiled by GCC, or a non-GCC compiler that claims to accept the
  1376. GNU C dialects, you can simply test '__GNUC__'. If you need to
  1377. write code which depends on a specific version, you must be more
  1378. careful. Each time the minor version is increased, the patch level
  1379. is reset to zero; each time the major version is increased, the
  1380. minor version and patch level are reset. If you wish to use the
  1381. predefined macros directly in the conditional, you will need to
  1382. write it like this:
  1383. /* Test for GCC > 3.2.0 */
  1384. #if __GNUC__ > 3 || \
  1385. (__GNUC__ == 3 && (__GNUC_MINOR__ > 2 || \
  1386. (__GNUC_MINOR__ == 2 && \
  1387. __GNUC_PATCHLEVEL__ > 0))
  1388. Another approach is to use the predefined macros to calculate a
  1389. single number, then compare that against a threshold:
  1390. #define GCC_VERSION (__GNUC__ * 10000 \
  1391. + __GNUC_MINOR__ * 100 \
  1392. + __GNUC_PATCHLEVEL__)
  1393. ...
  1394. /* Test for GCC > 3.2.0 */
  1395. #if GCC_VERSION > 30200
  1396. Many people find this form easier to understand.
  1397. '__GNUG__'
  1398. The GNU C++ compiler defines this. Testing it is equivalent to
  1399. testing '(__GNUC__ && __cplusplus)'.
  1400. '__STRICT_ANSI__'
  1401. GCC defines this macro if and only if the '-ansi' switch, or a
  1402. '-std' switch specifying strict conformance to some version of ISO
  1403. C or ISO C++, was specified when GCC was invoked. It is defined to
  1404. '1'. This macro exists primarily to direct GNU libc's header files
  1405. to use only definitions found in standard C.
  1406. '__BASE_FILE__'
  1407. This macro expands to the name of the main input file, in the form
  1408. of a C string constant. This is the source file that was specified
  1409. on the command line of the preprocessor or C compiler.
  1410. '__INCLUDE_LEVEL__'
  1411. This macro expands to a decimal integer constant that represents
  1412. the depth of nesting in include files. The value of this macro is
  1413. incremented on every '#include' directive and decremented at the
  1414. end of every included file. It starts out at 0, its value within
  1415. the base file specified on the command line.
  1416. '__ELF__'
  1417. This macro is defined if the target uses the ELF object format.
  1418. '__VERSION__'
  1419. This macro expands to a string constant which describes the version
  1420. of the compiler in use. You should not rely on its contents having
  1421. any particular form, but it can be counted on to contain at least
  1422. the release number.
  1423. '__OPTIMIZE__'
  1424. '__OPTIMIZE_SIZE__'
  1425. '__NO_INLINE__'
  1426. These macros describe the compilation mode. '__OPTIMIZE__' is
  1427. defined in all optimizing compilations. '__OPTIMIZE_SIZE__' is
  1428. defined if the compiler is optimizing for size, not speed.
  1429. '__NO_INLINE__' is defined if no functions will be inlined into
  1430. their callers (when not optimizing, or when inlining has been
  1431. specifically disabled by '-fno-inline').
  1432. These macros cause certain GNU header files to provide optimized
  1433. definitions, using macros or inline functions, of system library
  1434. functions. You should not use these macros in any way unless you
  1435. make sure that programs will execute with the same effect whether
  1436. or not they are defined. If they are defined, their value is 1.
  1437. '__GNUC_GNU_INLINE__'
  1438. GCC defines this macro if functions declared 'inline' will be
  1439. handled in GCC's traditional gnu90 mode. Object files will contain
  1440. externally visible definitions of all functions declared 'inline'
  1441. without 'extern' or 'static'. They will not contain any
  1442. definitions of any functions declared 'extern inline'.
  1443. '__GNUC_STDC_INLINE__'
  1444. GCC defines this macro if functions declared 'inline' will be
  1445. handled according to the ISO C99 or later standards. Object files
  1446. will contain externally visible definitions of all functions
  1447. declared 'extern inline'. They will not contain definitions of any
  1448. functions declared 'inline' without 'extern'.
  1449. If this macro is defined, GCC supports the 'gnu_inline' function
  1450. attribute as a way to always get the gnu90 behavior.
  1451. '__CHAR_UNSIGNED__'
  1452. GCC defines this macro if and only if the data type 'char' is
  1453. unsigned on the target machine. It exists to cause the standard
  1454. header file 'limits.h' to work correctly. You should not use this
  1455. macro yourself; instead, refer to the standard macros defined in
  1456. 'limits.h'.
  1457. '__WCHAR_UNSIGNED__'
  1458. Like '__CHAR_UNSIGNED__', this macro is defined if and only if the
  1459. data type 'wchar_t' is unsigned and the front-end is in C++ mode.
  1460. '__REGISTER_PREFIX__'
  1461. This macro expands to a single token (not a string constant) which
  1462. is the prefix applied to CPU register names in assembly language
  1463. for this target. You can use it to write assembly that is usable
  1464. in multiple environments. For example, in the 'm68k-aout'
  1465. environment it expands to nothing, but in the 'm68k-coff'
  1466. environment it expands to a single '%'.
  1467. '__USER_LABEL_PREFIX__'
  1468. This macro expands to a single token which is the prefix applied to
  1469. user labels (symbols visible to C code) in assembly. For example,
  1470. in the 'm68k-aout' environment it expands to an '_', but in the
  1471. 'm68k-coff' environment it expands to nothing.
  1472. This macro will have the correct definition even if
  1473. '-f(no-)underscores' is in use, but it will not be correct if
  1474. target-specific options that adjust this prefix are used (e.g. the
  1475. OSF/rose '-mno-underscores' option).
  1476. '__SIZE_TYPE__'
  1477. '__PTRDIFF_TYPE__'
  1478. '__WCHAR_TYPE__'
  1479. '__WINT_TYPE__'
  1480. '__INTMAX_TYPE__'
  1481. '__UINTMAX_TYPE__'
  1482. '__SIG_ATOMIC_TYPE__'
  1483. '__INT8_TYPE__'
  1484. '__INT16_TYPE__'
  1485. '__INT32_TYPE__'
  1486. '__INT64_TYPE__'
  1487. '__UINT8_TYPE__'
  1488. '__UINT16_TYPE__'
  1489. '__UINT32_TYPE__'
  1490. '__UINT64_TYPE__'
  1491. '__INT_LEAST8_TYPE__'
  1492. '__INT_LEAST16_TYPE__'
  1493. '__INT_LEAST32_TYPE__'
  1494. '__INT_LEAST64_TYPE__'
  1495. '__UINT_LEAST8_TYPE__'
  1496. '__UINT_LEAST16_TYPE__'
  1497. '__UINT_LEAST32_TYPE__'
  1498. '__UINT_LEAST64_TYPE__'
  1499. '__INT_FAST8_TYPE__'
  1500. '__INT_FAST16_TYPE__'
  1501. '__INT_FAST32_TYPE__'
  1502. '__INT_FAST64_TYPE__'
  1503. '__UINT_FAST8_TYPE__'
  1504. '__UINT_FAST16_TYPE__'
  1505. '__UINT_FAST32_TYPE__'
  1506. '__UINT_FAST64_TYPE__'
  1507. '__INTPTR_TYPE__'
  1508. '__UINTPTR_TYPE__'
  1509. These macros are defined to the correct underlying types for the
  1510. 'size_t', 'ptrdiff_t', 'wchar_t', 'wint_t', 'intmax_t',
  1511. 'uintmax_t', 'sig_atomic_t', 'int8_t', 'int16_t', 'int32_t',
  1512. 'int64_t', 'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t',
  1513. 'int_least8_t', 'int_least16_t', 'int_least32_t', 'int_least64_t',
  1514. 'uint_least8_t', 'uint_least16_t', 'uint_least32_t',
  1515. 'uint_least64_t', 'int_fast8_t', 'int_fast16_t', 'int_fast32_t',
  1516. 'int_fast64_t', 'uint_fast8_t', 'uint_fast16_t', 'uint_fast32_t',
  1517. 'uint_fast64_t', 'intptr_t', and 'uintptr_t' typedefs,
  1518. respectively. They exist to make the standard header files
  1519. 'stddef.h', 'stdint.h', and 'wchar.h' work correctly. You should
  1520. not use these macros directly; instead, include the appropriate
  1521. headers and use the typedefs. Some of these macros may not be
  1522. defined on particular systems if GCC does not provide a 'stdint.h'
  1523. header on those systems.
  1524. '__CHAR_BIT__'
  1525. Defined to the number of bits used in the representation of the
  1526. 'char' data type. It exists to make the standard header given
  1527. numerical limits work correctly. You should not use this macro
  1528. directly; instead, include the appropriate headers.
  1529. '__SCHAR_MAX__'
  1530. '__WCHAR_MAX__'
  1531. '__SHRT_MAX__'
  1532. '__INT_MAX__'
  1533. '__LONG_MAX__'
  1534. '__LONG_LONG_MAX__'
  1535. '__WINT_MAX__'
  1536. '__SIZE_MAX__'
  1537. '__PTRDIFF_MAX__'
  1538. '__INTMAX_MAX__'
  1539. '__UINTMAX_MAX__'
  1540. '__SIG_ATOMIC_MAX__'
  1541. '__INT8_MAX__'
  1542. '__INT16_MAX__'
  1543. '__INT32_MAX__'
  1544. '__INT64_MAX__'
  1545. '__UINT8_MAX__'
  1546. '__UINT16_MAX__'
  1547. '__UINT32_MAX__'
  1548. '__UINT64_MAX__'
  1549. '__INT_LEAST8_MAX__'
  1550. '__INT_LEAST16_MAX__'
  1551. '__INT_LEAST32_MAX__'
  1552. '__INT_LEAST64_MAX__'
  1553. '__UINT_LEAST8_MAX__'
  1554. '__UINT_LEAST16_MAX__'
  1555. '__UINT_LEAST32_MAX__'
  1556. '__UINT_LEAST64_MAX__'
  1557. '__INT_FAST8_MAX__'
  1558. '__INT_FAST16_MAX__'
  1559. '__INT_FAST32_MAX__'
  1560. '__INT_FAST64_MAX__'
  1561. '__UINT_FAST8_MAX__'
  1562. '__UINT_FAST16_MAX__'
  1563. '__UINT_FAST32_MAX__'
  1564. '__UINT_FAST64_MAX__'
  1565. '__INTPTR_MAX__'
  1566. '__UINTPTR_MAX__'
  1567. '__WCHAR_MIN__'
  1568. '__WINT_MIN__'
  1569. '__SIG_ATOMIC_MIN__'
  1570. Defined to the maximum value of the 'signed char', 'wchar_t',
  1571. 'signed short', 'signed int', 'signed long', 'signed long long',
  1572. 'wint_t', 'size_t', 'ptrdiff_t', 'intmax_t', 'uintmax_t',
  1573. 'sig_atomic_t', 'int8_t', 'int16_t', 'int32_t', 'int64_t',
  1574. 'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t', 'int_least8_t',
  1575. 'int_least16_t', 'int_least32_t', 'int_least64_t', 'uint_least8_t',
  1576. 'uint_least16_t', 'uint_least32_t', 'uint_least64_t',
  1577. 'int_fast8_t', 'int_fast16_t', 'int_fast32_t', 'int_fast64_t',
  1578. 'uint_fast8_t', 'uint_fast16_t', 'uint_fast32_t', 'uint_fast64_t',
  1579. 'intptr_t', and 'uintptr_t' types and to the minimum value of the
  1580. 'wchar_t', 'wint_t', and 'sig_atomic_t' types respectively. They
  1581. exist to make the standard header given numerical limits work
  1582. correctly. You should not use these macros directly; instead,
  1583. include the appropriate headers. Some of these macros may not be
  1584. defined on particular systems if GCC does not provide a 'stdint.h'
  1585. header on those systems.
  1586. '__INT8_C'
  1587. '__INT16_C'
  1588. '__INT32_C'
  1589. '__INT64_C'
  1590. '__UINT8_C'
  1591. '__UINT16_C'
  1592. '__UINT32_C'
  1593. '__UINT64_C'
  1594. '__INTMAX_C'
  1595. '__UINTMAX_C'
  1596. Defined to implementations of the standard 'stdint.h' macros with
  1597. the same names without the leading '__'. They exist the make the
  1598. implementation of that header work correctly. You should not use
  1599. these macros directly; instead, include the appropriate headers.
  1600. Some of these macros may not be defined on particular systems if
  1601. GCC does not provide a 'stdint.h' header on those systems.
  1602. '__SCHAR_WIDTH__'
  1603. '__SHRT_WIDTH__'
  1604. '__INT_WIDTH__'
  1605. '__LONG_WIDTH__'
  1606. '__LONG_LONG_WIDTH__'
  1607. '__PTRDIFF_WIDTH__'
  1608. '__SIG_ATOMIC_WIDTH__'
  1609. '__SIZE_WIDTH__'
  1610. '__WCHAR_WIDTH__'
  1611. '__WINT_WIDTH__'
  1612. '__INT_LEAST8_WIDTH__'
  1613. '__INT_LEAST16_WIDTH__'
  1614. '__INT_LEAST32_WIDTH__'
  1615. '__INT_LEAST64_WIDTH__'
  1616. '__INT_FAST8_WIDTH__'
  1617. '__INT_FAST16_WIDTH__'
  1618. '__INT_FAST32_WIDTH__'
  1619. '__INT_FAST64_WIDTH__'
  1620. '__INTPTR_WIDTH__'
  1621. '__INTMAX_WIDTH__'
  1622. Defined to the bit widths of the corresponding types. They exist
  1623. to make the implementations of 'limits.h' and 'stdint.h' behave
  1624. correctly. You should not use these macros directly; instead,
  1625. include the appropriate headers. Some of these macros may not be
  1626. defined on particular systems if GCC does not provide a 'stdint.h'
  1627. header on those systems.
  1628. '__SIZEOF_INT__'
  1629. '__SIZEOF_LONG__'
  1630. '__SIZEOF_LONG_LONG__'
  1631. '__SIZEOF_SHORT__'
  1632. '__SIZEOF_POINTER__'
  1633. '__SIZEOF_FLOAT__'
  1634. '__SIZEOF_DOUBLE__'
  1635. '__SIZEOF_LONG_DOUBLE__'
  1636. '__SIZEOF_SIZE_T__'
  1637. '__SIZEOF_WCHAR_T__'
  1638. '__SIZEOF_WINT_T__'
  1639. '__SIZEOF_PTRDIFF_T__'
  1640. Defined to the number of bytes of the C standard data types: 'int',
  1641. 'long', 'long long', 'short', 'void *', 'float', 'double', 'long
  1642. double', 'size_t', 'wchar_t', 'wint_t' and 'ptrdiff_t'.
  1643. '__BYTE_ORDER__'
  1644. '__ORDER_LITTLE_ENDIAN__'
  1645. '__ORDER_BIG_ENDIAN__'
  1646. '__ORDER_PDP_ENDIAN__'
  1647. '__BYTE_ORDER__' is defined to one of the values
  1648. '__ORDER_LITTLE_ENDIAN__', '__ORDER_BIG_ENDIAN__', or
  1649. '__ORDER_PDP_ENDIAN__' to reflect the layout of multi-byte and
  1650. multi-word quantities in memory. If '__BYTE_ORDER__' is equal to
  1651. '__ORDER_LITTLE_ENDIAN__' or '__ORDER_BIG_ENDIAN__', then
  1652. multi-byte and multi-word quantities are laid out identically: the
  1653. byte (word) at the lowest address is the least significant or most
  1654. significant byte (word) of the quantity, respectively. If
  1655. '__BYTE_ORDER__' is equal to '__ORDER_PDP_ENDIAN__', then bytes in
  1656. 16-bit words are laid out in a little-endian fashion, whereas the
  1657. 16-bit subwords of a 32-bit quantity are laid out in big-endian
  1658. fashion.
  1659. You should use these macros for testing like this:
  1660. /* Test for a little-endian machine */
  1661. #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
  1662. '__FLOAT_WORD_ORDER__'
  1663. '__FLOAT_WORD_ORDER__' is defined to one of the values
  1664. '__ORDER_LITTLE_ENDIAN__' or '__ORDER_BIG_ENDIAN__' to reflect the
  1665. layout of the words of multi-word floating-point quantities.
  1666. '__DEPRECATED'
  1667. This macro is defined, with value 1, when compiling a C++ source
  1668. file with warnings about deprecated constructs enabled. These
  1669. warnings are enabled by default, but can be disabled with
  1670. '-Wno-deprecated'.
  1671. '__EXCEPTIONS'
  1672. This macro is defined, with value 1, when compiling a C++ source
  1673. file with exceptions enabled. If '-fno-exceptions' is used when
  1674. compiling the file, then this macro is not defined.
  1675. '__GXX_RTTI'
  1676. This macro is defined, with value 1, when compiling a C++ source
  1677. file with runtime type identification enabled. If '-fno-rtti' is
  1678. used when compiling the file, then this macro is not defined.
  1679. '__USING_SJLJ_EXCEPTIONS__'
  1680. This macro is defined, with value 1, if the compiler uses the old
  1681. mechanism based on 'setjmp' and 'longjmp' for exception handling.
  1682. '__GXX_EXPERIMENTAL_CXX0X__'
  1683. This macro is defined when compiling a C++ source file with the
  1684. option '-std=c++0x' or '-std=gnu++0x'. It indicates that some
  1685. features likely to be included in C++0x are available. Note that
  1686. these features are experimental, and may change or be removed in
  1687. future versions of GCC.
  1688. '__GXX_WEAK__'
  1689. This macro is defined when compiling a C++ source file. It has the
  1690. value 1 if the compiler will use weak symbols, COMDAT sections, or
  1691. other similar techniques to collapse symbols with "vague linkage"
  1692. that are defined in multiple translation units. If the compiler
  1693. will not collapse such symbols, this macro is defined with value 0.
  1694. In general, user code should not need to make use of this macro;
  1695. the purpose of this macro is to ease implementation of the C++
  1696. runtime library provided with G++.
  1697. '__NEXT_RUNTIME__'
  1698. This macro is defined, with value 1, if (and only if) the NeXT
  1699. runtime (as in '-fnext-runtime') is in use for Objective-C. If the
  1700. GNU runtime is used, this macro is not defined, so that you can use
  1701. this macro to determine which runtime (NeXT or GNU) is being used.
  1702. '__LP64__'
  1703. '_LP64'
  1704. These macros are defined, with value 1, if (and only if) the
  1705. compilation is for a target where 'long int' and pointer both use
  1706. 64-bits and 'int' uses 32-bit.
  1707. '__SSP__'
  1708. This macro is defined, with value 1, when '-fstack-protector' is in
  1709. use.
  1710. '__SSP_ALL__'
  1711. This macro is defined, with value 2, when '-fstack-protector-all'
  1712. is in use.
  1713. '__SSP_STRONG__'
  1714. This macro is defined, with value 3, when
  1715. '-fstack-protector-strong' is in use.
  1716. '__SSP_EXPLICIT__'
  1717. This macro is defined, with value 4, when
  1718. '-fstack-protector-explicit' is in use.
  1719. '__SANITIZE_ADDRESS__'
  1720. This macro is defined, with value 1, when '-fsanitize=address' or
  1721. '-fsanitize=kernel-address' are in use.
  1722. '__SANITIZE_THREAD__'
  1723. This macro is defined, with value 1, when '-fsanitize=thread' is in
  1724. use.
  1725. '__TIMESTAMP__'
  1726. This macro expands to a string constant that describes the date and
  1727. time of the last modification of the current source file. The
  1728. string constant contains abbreviated day of the week, month, day of
  1729. the month, time in hh:mm:ss form, year and looks like
  1730. '"Sun Sep 16 01:03:52 1973"'. If the day of the month is less than
  1731. 10, it is padded with a space on the left.
  1732. If GCC cannot determine the current date, it will emit a warning
  1733. message (once per compilation) and '__TIMESTAMP__' will expand to
  1734. '"??? ??? ?? ??:??:?? ????"'.
  1735. '__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1'
  1736. '__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2'
  1737. '__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4'
  1738. '__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8'
  1739. '__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16'
  1740. These macros are defined when the target processor supports atomic
  1741. compare and swap operations on operands 1, 2, 4, 8 or 16 bytes in
  1742. length, respectively.
  1743. '__GCC_HAVE_DWARF2_CFI_ASM'
  1744. This macro is defined when the compiler is emitting DWARF CFI
  1745. directives to the assembler. When this is defined, it is possible
  1746. to emit those same directives in inline assembly.
  1747. '__FP_FAST_FMA'
  1748. '__FP_FAST_FMAF'
  1749. '__FP_FAST_FMAL'
  1750. These macros are defined with value 1 if the backend supports the
  1751. 'fma', 'fmaf', and 'fmal' builtin functions, so that the include
  1752. file 'math.h' can define the macros 'FP_FAST_FMA', 'FP_FAST_FMAF',
  1753. and 'FP_FAST_FMAL' for compatibility with the 1999 C standard.
  1754. '__FP_FAST_FMAF16'
  1755. '__FP_FAST_FMAF32'
  1756. '__FP_FAST_FMAF64'
  1757. '__FP_FAST_FMAF128'
  1758. '__FP_FAST_FMAF32X'
  1759. '__FP_FAST_FMAF64X'
  1760. '__FP_FAST_FMAF128X'
  1761. These macros are defined with the value 1 if the backend supports
  1762. the 'fma' functions using the additional '_FloatN' and '_FloatNx'
  1763. types that are defined in ISO/IEC TS 18661-3:2015. The include
  1764. file 'math.h' can define the 'FP_FAST_FMAFN' and 'FP_FAST_FMAFNx'
  1765. macros if the user defined '__STDC_WANT_IEC_60559_TYPES_EXT__'
  1766. before including 'math.h'.
  1767. '__GCC_IEC_559'
  1768. This macro is defined to indicate the intended level of support for
  1769. IEEE 754 (IEC 60559) floating-point arithmetic. It expands to a
  1770. nonnegative integer value. If 0, it indicates that the combination
  1771. of the compiler configuration and the command-line options is not
  1772. intended to support IEEE 754 arithmetic for 'float' and 'double' as
  1773. defined in C99 and C11 Annex F (for example, that the standard
  1774. rounding modes and exceptions are not supported, or that
  1775. optimizations are enabled that conflict with IEEE 754 semantics).
  1776. If 1, it indicates that IEEE 754 arithmetic is intended to be
  1777. supported; this does not mean that all relevant language features
  1778. are supported by GCC. If 2 or more, it additionally indicates
  1779. support for IEEE 754-2008 (in particular, that the binary encodings
  1780. for quiet and signaling NaNs are as specified in IEEE 754-2008).
  1781. This macro does not indicate the default state of command-line
  1782. options that control optimizations that C99 and C11 permit to be
  1783. controlled by standard pragmas, where those standards do not
  1784. require a particular default state. It does not indicate whether
  1785. optimizations respect signaling NaN semantics (the macro for that
  1786. is '__SUPPORT_SNAN__'). It does not indicate support for decimal
  1787. floating point or the IEEE 754 binary16 and binary128 types.
  1788. '__GCC_IEC_559_COMPLEX'
  1789. This macro is defined to indicate the intended level of support for
  1790. IEEE 754 (IEC 60559) floating-point arithmetic for complex numbers,
  1791. as defined in C99 and C11 Annex G. It expands to a nonnegative
  1792. integer value. If 0, it indicates that the combination of the
  1793. compiler configuration and the command-line options is not intended
  1794. to support Annex G requirements (for example, because
  1795. '-fcx-limited-range' was used). If 1 or more, it indicates that it
  1796. is intended to support those requirements; this does not mean that
  1797. all relevant language features are supported by GCC.
  1798. '__NO_MATH_ERRNO__'
  1799. This macro is defined if '-fno-math-errno' is used, or enabled by
  1800. another option such as '-ffast-math' or by default.
  1801. 
  1802. File: cpp.info, Node: System-specific Predefined Macros, Next: C++ Named Operators, Prev: Common Predefined Macros, Up: Predefined Macros
  1803. 3.7.3 System-specific Predefined Macros
  1804. ---------------------------------------
  1805. The C preprocessor normally predefines several macros that indicate what
  1806. type of system and machine is in use. They are obviously different on
  1807. each target supported by GCC. This manual, being for all systems and
  1808. machines, cannot tell you what their names are, but you can use 'cpp
  1809. -dM' to see them all. *Note Invocation::. All system-specific
  1810. predefined macros expand to a constant value, so you can test them with
  1811. either '#ifdef' or '#if'.
  1812. The C standard requires that all system-specific macros be part of
  1813. the "reserved namespace". All names which begin with two underscores,
  1814. or an underscore and a capital letter, are reserved for the compiler and
  1815. library to use as they wish. However, historically system-specific
  1816. macros have had names with no special prefix; for instance, it is common
  1817. to find 'unix' defined on Unix systems. For all such macros, GCC
  1818. provides a parallel macro with two underscores added at the beginning
  1819. and the end. If 'unix' is defined, '__unix__' will be defined too.
  1820. There will never be more than two underscores; the parallel of '_mips'
  1821. is '__mips__'.
  1822. When the '-ansi' option, or any '-std' option that requests strict
  1823. conformance, is given to the compiler, all the system-specific
  1824. predefined macros outside the reserved namespace are suppressed. The
  1825. parallel macros, inside the reserved namespace, remain defined.
  1826. We are slowly phasing out all predefined macros which are outside the
  1827. reserved namespace. You should never use them in new programs, and we
  1828. encourage you to correct older code to use the parallel macros whenever
  1829. you find it. We don't recommend you use the system-specific macros that
  1830. are in the reserved namespace, either. It is better in the long run to
  1831. check specifically for features you need, using a tool such as
  1832. 'autoconf'.
  1833. 
  1834. File: cpp.info, Node: C++ Named Operators, Prev: System-specific Predefined Macros, Up: Predefined Macros
  1835. 3.7.4 C++ Named Operators
  1836. -------------------------
  1837. In C++, there are eleven keywords which are simply alternate spellings
  1838. of operators normally written with punctuation. These keywords are
  1839. treated as such even in the preprocessor. They function as operators in
  1840. '#if', and they cannot be defined as macros or poisoned. In C, you can
  1841. request that those keywords take their C++ meaning by including
  1842. 'iso646.h'. That header defines each one as a normal object-like macro
  1843. expanding to the appropriate punctuator.
  1844. These are the named operators and their corresponding punctuators:
  1845. Named Operator Punctuator
  1846. 'and' '&&'
  1847. 'and_eq' '&='
  1848. 'bitand' '&'
  1849. 'bitor' '|'
  1850. 'compl' '~'
  1851. 'not' '!'
  1852. 'not_eq' '!='
  1853. 'or' '||'
  1854. 'or_eq' '|='
  1855. 'xor' '^'
  1856. 'xor_eq' '^='
  1857. 
  1858. File: cpp.info, Node: Undefining and Redefining Macros, Next: Directives Within Macro Arguments, Prev: Predefined Macros, Up: Macros
  1859. 3.8 Undefining and Redefining Macros
  1860. ====================================
  1861. If a macro ceases to be useful, it may be "undefined" with the '#undef'
  1862. directive. '#undef' takes a single argument, the name of the macro to
  1863. undefine. You use the bare macro name, even if the macro is
  1864. function-like. It is an error if anything appears on the line after the
  1865. macro name. '#undef' has no effect if the name is not a macro.
  1866. #define FOO 4
  1867. x = FOO; ==> x = 4;
  1868. #undef FOO
  1869. x = FOO; ==> x = FOO;
  1870. Once a macro has been undefined, that identifier may be "redefined"
  1871. as a macro by a subsequent '#define' directive. The new definition need
  1872. not have any resemblance to the old definition.
  1873. However, if an identifier which is currently a macro is redefined,
  1874. then the new definition must be "effectively the same" as the old one.
  1875. Two macro definitions are effectively the same if:
  1876. * Both are the same type of macro (object- or function-like).
  1877. * All the tokens of the replacement list are the same.
  1878. * If there are any parameters, they are the same.
  1879. * Whitespace appears in the same places in both. It need not be
  1880. exactly the same amount of whitespace, though. Remember that
  1881. comments count as whitespace.
  1882. These definitions are effectively the same:
  1883. #define FOUR (2 + 2)
  1884. #define FOUR (2 + 2)
  1885. #define FOUR (2 /* two */ + 2)
  1886. but these are not:
  1887. #define FOUR (2 + 2)
  1888. #define FOUR ( 2+2 )
  1889. #define FOUR (2 * 2)
  1890. #define FOUR(score,and,seven,years,ago) (2 + 2)
  1891. If a macro is redefined with a definition that is not effectively the
  1892. same as the old one, the preprocessor issues a warning and changes the
  1893. macro to use the new definition. If the new definition is effectively
  1894. the same, the redefinition is silently ignored. This allows, for
  1895. instance, two different headers to define a common macro. The
  1896. preprocessor will only complain if the definitions do not match.
  1897. 
  1898. File: cpp.info, Node: Directives Within Macro Arguments, Next: Macro Pitfalls, Prev: Undefining and Redefining Macros, Up: Macros
  1899. 3.9 Directives Within Macro Arguments
  1900. =====================================
  1901. Occasionally it is convenient to use preprocessor directives within the
  1902. arguments of a macro. The C and C++ standards declare that behavior in
  1903. these cases is undefined. GNU CPP processes arbitrary directives within
  1904. macro arguments in exactly the same way as it would have processed the
  1905. directive were the function-like macro invocation not present.
  1906. If, within a macro invocation, that macro is redefined, then the new
  1907. definition takes effect in time for argument pre-expansion, but the
  1908. original definition is still used for argument replacement. Here is a
  1909. pathological example:
  1910. #define f(x) x x
  1911. f (1
  1912. #undef f
  1913. #define f 2
  1914. f)
  1915. which expands to
  1916. 1 2 1 2
  1917. with the semantics described above.
  1918. 
  1919. File: cpp.info, Node: Macro Pitfalls, Prev: Directives Within Macro Arguments, Up: Macros
  1920. 3.10 Macro Pitfalls
  1921. ===================
  1922. In this section we describe some special rules that apply to macros and
  1923. macro expansion, and point out certain cases in which the rules have
  1924. counter-intuitive consequences that you must watch out for.
  1925. * Menu:
  1926. * Misnesting::
  1927. * Operator Precedence Problems::
  1928. * Swallowing the Semicolon::
  1929. * Duplication of Side Effects::
  1930. * Self-Referential Macros::
  1931. * Argument Prescan::
  1932. * Newlines in Arguments::
  1933. 
  1934. File: cpp.info, Node: Misnesting, Next: Operator Precedence Problems, Up: Macro Pitfalls
  1935. 3.10.1 Misnesting
  1936. -----------------
  1937. When a macro is called with arguments, the arguments are substituted
  1938. into the macro body and the result is checked, together with the rest of
  1939. the input file, for more macro calls. It is possible to piece together
  1940. a macro call coming partially from the macro body and partially from the
  1941. arguments. For example,
  1942. #define twice(x) (2*(x))
  1943. #define call_with_1(x) x(1)
  1944. call_with_1 (twice)
  1945. ==> twice(1)
  1946. ==> (2*(1))
  1947. Macro definitions do not have to have balanced parentheses. By
  1948. writing an unbalanced open parenthesis in a macro body, it is possible
  1949. to create a macro call that begins inside the macro body but ends
  1950. outside of it. For example,
  1951. #define strange(file) fprintf (file, "%s %d",
  1952. ...
  1953. strange(stderr) p, 35)
  1954. ==> fprintf (stderr, "%s %d", p, 35)
  1955. The ability to piece together a macro call can be useful, but the use
  1956. of unbalanced open parentheses in a macro body is just confusing, and
  1957. should be avoided.
  1958. 
  1959. File: cpp.info, Node: Operator Precedence Problems, Next: Swallowing the Semicolon, Prev: Misnesting, Up: Macro Pitfalls
  1960. 3.10.2 Operator Precedence Problems
  1961. -----------------------------------
  1962. You may have noticed that in most of the macro definition examples shown
  1963. above, each occurrence of a macro argument name had parentheses around
  1964. it. In addition, another pair of parentheses usually surround the
  1965. entire macro definition. Here is why it is best to write macros that
  1966. way.
  1967. Suppose you define a macro as follows,
  1968. #define ceil_div(x, y) (x + y - 1) / y
  1969. whose purpose is to divide, rounding up. (One use for this operation is
  1970. to compute how many 'int' objects are needed to hold a certain number of
  1971. 'char' objects.) Then suppose it is used as follows:
  1972. a = ceil_div (b & c, sizeof (int));
  1973. ==> a = (b & c + sizeof (int) - 1) / sizeof (int);
  1974. This does not do what is intended. The operator-precedence rules of C
  1975. make it equivalent to this:
  1976. a = (b & (c + sizeof (int) - 1)) / sizeof (int);
  1977. What we want is this:
  1978. a = ((b & c) + sizeof (int) - 1)) / sizeof (int);
  1979. Defining the macro as
  1980. #define ceil_div(x, y) ((x) + (y) - 1) / (y)
  1981. provides the desired result.
  1982. Unintended grouping can result in another way. Consider 'sizeof
  1983. ceil_div(1, 2)'. That has the appearance of a C expression that would
  1984. compute the size of the type of 'ceil_div (1, 2)', but in fact it means
  1985. something very different. Here is what it expands to:
  1986. sizeof ((1) + (2) - 1) / (2)
  1987. This would take the size of an integer and divide it by two. The
  1988. precedence rules have put the division outside the 'sizeof' when it was
  1989. intended to be inside.
  1990. Parentheses around the entire macro definition prevent such problems.
  1991. Here, then, is the recommended way to define 'ceil_div':
  1992. #define ceil_div(x, y) (((x) + (y) - 1) / (y))
  1993. 
  1994. File: cpp.info, Node: Swallowing the Semicolon, Next: Duplication of Side Effects, Prev: Operator Precedence Problems, Up: Macro Pitfalls
  1995. 3.10.3 Swallowing the Semicolon
  1996. -------------------------------
  1997. Often it is desirable to define a macro that expands into a compound
  1998. statement. Consider, for example, the following macro, that advances a
  1999. pointer (the argument 'p' says where to find it) across whitespace
  2000. characters:
  2001. #define SKIP_SPACES(p, limit) \
  2002. { char *lim = (limit); \
  2003. while (p < lim) { \
  2004. if (*p++ != ' ') { \
  2005. p--; break; }}}
  2006. Here backslash-newline is used to split the macro definition, which must
  2007. be a single logical line, so that it resembles the way such code would
  2008. be laid out if not part of a macro definition.
  2009. A call to this macro might be 'SKIP_SPACES (p, lim)'. Strictly
  2010. speaking, the call expands to a compound statement, which is a complete
  2011. statement with no need for a semicolon to end it. However, since it
  2012. looks like a function call, it minimizes confusion if you can use it
  2013. like a function call, writing a semicolon afterward, as in 'SKIP_SPACES
  2014. (p, lim);'
  2015. This can cause trouble before 'else' statements, because the
  2016. semicolon is actually a null statement. Suppose you write
  2017. if (*p != 0)
  2018. SKIP_SPACES (p, lim);
  2019. else ...
  2020. The presence of two statements--the compound statement and a null
  2021. statement--in between the 'if' condition and the 'else' makes invalid C
  2022. code.
  2023. The definition of the macro 'SKIP_SPACES' can be altered to solve
  2024. this problem, using a 'do ... while' statement. Here is how:
  2025. #define SKIP_SPACES(p, limit) \
  2026. do { char *lim = (limit); \
  2027. while (p < lim) { \
  2028. if (*p++ != ' ') { \
  2029. p--; break; }}} \
  2030. while (0)
  2031. Now 'SKIP_SPACES (p, lim);' expands into
  2032. do {...} while (0);
  2033. which is one statement. The loop executes exactly once; most compilers
  2034. generate no extra code for it.
  2035. 
  2036. File: cpp.info, Node: Duplication of Side Effects, Next: Self-Referential Macros, Prev: Swallowing the Semicolon, Up: Macro Pitfalls
  2037. 3.10.4 Duplication of Side Effects
  2038. ----------------------------------
  2039. Many C programs define a macro 'min', for "minimum", like this:
  2040. #define min(X, Y) ((X) < (Y) ? (X) : (Y))
  2041. When you use this macro with an argument containing a side effect, as
  2042. shown here,
  2043. next = min (x + y, foo (z));
  2044. it expands as follows:
  2045. next = ((x + y) < (foo (z)) ? (x + y) : (foo (z)));
  2046. where 'x + y' has been substituted for 'X' and 'foo (z)' for 'Y'.
  2047. The function 'foo' is used only once in the statement as it appears
  2048. in the program, but the expression 'foo (z)' has been substituted twice
  2049. into the macro expansion. As a result, 'foo' might be called two times
  2050. when the statement is executed. If it has side effects or if it takes a
  2051. long time to compute, the results might not be what you intended. We
  2052. say that 'min' is an "unsafe" macro.
  2053. The best solution to this problem is to define 'min' in a way that
  2054. computes the value of 'foo (z)' only once. The C language offers no
  2055. standard way to do this, but it can be done with GNU extensions as
  2056. follows:
  2057. #define min(X, Y) \
  2058. ({ typeof (X) x_ = (X); \
  2059. typeof (Y) y_ = (Y); \
  2060. (x_ < y_) ? x_ : y_; })
  2061. The '({ ... })' notation produces a compound statement that acts as
  2062. an expression. Its value is the value of its last statement. This
  2063. permits us to define local variables and assign each argument to one.
  2064. The local variables have underscores after their names to reduce the
  2065. risk of conflict with an identifier of wider scope (it is impossible to
  2066. avoid this entirely). Now each argument is evaluated exactly once.
  2067. If you do not wish to use GNU C extensions, the only solution is to
  2068. be careful when _using_ the macro 'min'. For example, you can calculate
  2069. the value of 'foo (z)', save it in a variable, and use that variable in
  2070. 'min':
  2071. #define min(X, Y) ((X) < (Y) ? (X) : (Y))
  2072. ...
  2073. {
  2074. int tem = foo (z);
  2075. next = min (x + y, tem);
  2076. }
  2077. (where we assume that 'foo' returns type 'int').
  2078. 
  2079. File: cpp.info, Node: Self-Referential Macros, Next: Argument Prescan, Prev: Duplication of Side Effects, Up: Macro Pitfalls
  2080. 3.10.5 Self-Referential Macros
  2081. ------------------------------
  2082. A "self-referential" macro is one whose name appears in its definition.
  2083. Recall that all macro definitions are rescanned for more macros to
  2084. replace. If the self-reference were considered a use of the macro, it
  2085. would produce an infinitely large expansion. To prevent this, the
  2086. self-reference is not considered a macro call. It is passed into the
  2087. preprocessor output unchanged. Consider an example:
  2088. #define foo (4 + foo)
  2089. where 'foo' is also a variable in your program.
  2090. Following the ordinary rules, each reference to 'foo' will expand
  2091. into '(4 + foo)'; then this will be rescanned and will expand into '(4 +
  2092. (4 + foo))'; and so on until the computer runs out of memory.
  2093. The self-reference rule cuts this process short after one step, at
  2094. '(4 + foo)'. Therefore, this macro definition has the possibly useful
  2095. effect of causing the program to add 4 to the value of 'foo' wherever
  2096. 'foo' is referred to.
  2097. In most cases, it is a bad idea to take advantage of this feature. A
  2098. person reading the program who sees that 'foo' is a variable will not
  2099. expect that it is a macro as well. The reader will come across the
  2100. identifier 'foo' in the program and think its value should be that of
  2101. the variable 'foo', whereas in fact the value is four greater.
  2102. One common, useful use of self-reference is to create a macro which
  2103. expands to itself. If you write
  2104. #define EPERM EPERM
  2105. then the macro 'EPERM' expands to 'EPERM'. Effectively, it is left
  2106. alone by the preprocessor whenever it's used in running text. You can
  2107. tell that it's a macro with '#ifdef'. You might do this if you want to
  2108. define numeric constants with an 'enum', but have '#ifdef' be true for
  2109. each constant.
  2110. If a macro 'x' expands to use a macro 'y', and the expansion of 'y'
  2111. refers to the macro 'x', that is an "indirect self-reference" of 'x'.
  2112. 'x' is not expanded in this case either. Thus, if we have
  2113. #define x (4 + y)
  2114. #define y (2 * x)
  2115. then 'x' and 'y' expand as follows:
  2116. x ==> (4 + y)
  2117. ==> (4 + (2 * x))
  2118. y ==> (2 * x)
  2119. ==> (2 * (4 + y))
  2120. Each macro is expanded when it appears in the definition of the other
  2121. macro, but not when it indirectly appears in its own definition.
  2122. 
  2123. File: cpp.info, Node: Argument Prescan, Next: Newlines in Arguments, Prev: Self-Referential Macros, Up: Macro Pitfalls
  2124. 3.10.6 Argument Prescan
  2125. -----------------------
  2126. Macro arguments are completely macro-expanded before they are
  2127. substituted into a macro body, unless they are stringized or pasted with
  2128. other tokens. After substitution, the entire macro body, including the
  2129. substituted arguments, is scanned again for macros to be expanded. The
  2130. result is that the arguments are scanned _twice_ to expand macro calls
  2131. in them.
  2132. Most of the time, this has no effect. If the argument contained any
  2133. macro calls, they are expanded during the first scan. The result
  2134. therefore contains no macro calls, so the second scan does not change
  2135. it. If the argument were substituted as given, with no prescan, the
  2136. single remaining scan would find the same macro calls and produce the
  2137. same results.
  2138. You might expect the double scan to change the results when a
  2139. self-referential macro is used in an argument of another macro (*note
  2140. Self-Referential Macros::): the self-referential macro would be expanded
  2141. once in the first scan, and a second time in the second scan. However,
  2142. this is not what happens. The self-references that do not expand in the
  2143. first scan are marked so that they will not expand in the second scan
  2144. either.
  2145. You might wonder, "Why mention the prescan, if it makes no
  2146. difference? And why not skip it and make the preprocessor faster?" The
  2147. answer is that the prescan does make a difference in three special
  2148. cases:
  2149. * Nested calls to a macro.
  2150. We say that "nested" calls to a macro occur when a macro's argument
  2151. contains a call to that very macro. For example, if 'f' is a macro
  2152. that expects one argument, 'f (f (1))' is a nested pair of calls to
  2153. 'f'. The desired expansion is made by expanding 'f (1)' and
  2154. substituting that into the definition of 'f'. The prescan causes
  2155. the expected result to happen. Without the prescan, 'f (1)' itself
  2156. would be substituted as an argument, and the inner use of 'f' would
  2157. appear during the main scan as an indirect self-reference and would
  2158. not be expanded.
  2159. * Macros that call other macros that stringize or concatenate.
  2160. If an argument is stringized or concatenated, the prescan does not
  2161. occur. If you _want_ to expand a macro, then stringize or
  2162. concatenate its expansion, you can do that by causing one macro to
  2163. call another macro that does the stringizing or concatenation. For
  2164. instance, if you have
  2165. #define AFTERX(x) X_ ## x
  2166. #define XAFTERX(x) AFTERX(x)
  2167. #define TABLESIZE 1024
  2168. #define BUFSIZE TABLESIZE
  2169. then 'AFTERX(BUFSIZE)' expands to 'X_BUFSIZE', and
  2170. 'XAFTERX(BUFSIZE)' expands to 'X_1024'. (Not to 'X_TABLESIZE'.
  2171. Prescan always does a complete expansion.)
  2172. * Macros used in arguments, whose expansions contain unshielded
  2173. commas.
  2174. This can cause a macro expanded on the second scan to be called
  2175. with the wrong number of arguments. Here is an example:
  2176. #define foo a,b
  2177. #define bar(x) lose(x)
  2178. #define lose(x) (1 + (x))
  2179. We would like 'bar(foo)' to turn into '(1 + (foo))', which would
  2180. then turn into '(1 + (a,b))'. Instead, 'bar(foo)' expands into
  2181. 'lose(a,b)', and you get an error because 'lose' requires a single
  2182. argument. In this case, the problem is easily solved by the same
  2183. parentheses that ought to be used to prevent misnesting of
  2184. arithmetic operations:
  2185. #define foo (a,b)
  2186. or
  2187. #define bar(x) lose((x))
  2188. The extra pair of parentheses prevents the comma in 'foo''s
  2189. definition from being interpreted as an argument separator.
  2190. 
  2191. File: cpp.info, Node: Newlines in Arguments, Prev: Argument Prescan, Up: Macro Pitfalls
  2192. 3.10.7 Newlines in Arguments
  2193. ----------------------------
  2194. The invocation of a function-like macro can extend over many logical
  2195. lines. However, in the present implementation, the entire expansion
  2196. comes out on one line. Thus line numbers emitted by the compiler or
  2197. debugger refer to the line the invocation started on, which might be
  2198. different to the line containing the argument causing the problem.
  2199. Here is an example illustrating this:
  2200. #define ignore_second_arg(a,b,c) a; c
  2201. ignore_second_arg (foo (),
  2202. ignored (),
  2203. syntax error);
  2204. The syntax error triggered by the tokens 'syntax error' results in an
  2205. error message citing line three--the line of ignore_second_arg-- even
  2206. though the problematic code comes from line five.
  2207. We consider this a bug, and intend to fix it in the near future.
  2208. 
  2209. File: cpp.info, Node: Conditionals, Next: Diagnostics, Prev: Macros, Up: Top
  2210. 4 Conditionals
  2211. **************
  2212. A "conditional" is a directive that instructs the preprocessor to select
  2213. whether or not to include a chunk of code in the final token stream
  2214. passed to the compiler. Preprocessor conditionals can test arithmetic
  2215. expressions, or whether a name is defined as a macro, or both
  2216. simultaneously using the special 'defined' operator.
  2217. A conditional in the C preprocessor resembles in some ways an 'if'
  2218. statement in C, but it is important to understand the difference between
  2219. them. The condition in an 'if' statement is tested during the execution
  2220. of your program. Its purpose is to allow your program to behave
  2221. differently from run to run, depending on the data it is operating on.
  2222. The condition in a preprocessing conditional directive is tested when
  2223. your program is compiled. Its purpose is to allow different code to be
  2224. included in the program depending on the situation at the time of
  2225. compilation.
  2226. However, the distinction is becoming less clear. Modern compilers
  2227. often do test 'if' statements when a program is compiled, if their
  2228. conditions are known not to vary at run time, and eliminate code which
  2229. can never be executed. If you can count on your compiler to do this,
  2230. you may find that your program is more readable if you use 'if'
  2231. statements with constant conditions (perhaps determined by macros). Of
  2232. course, you can only use this to exclude code, not type definitions or
  2233. other preprocessing directives, and you can only do it if the code
  2234. remains syntactically valid when it is not to be used.
  2235. * Menu:
  2236. * Conditional Uses::
  2237. * Conditional Syntax::
  2238. * Deleted Code::
  2239. 
  2240. File: cpp.info, Node: Conditional Uses, Next: Conditional Syntax, Up: Conditionals
  2241. 4.1 Conditional Uses
  2242. ====================
  2243. There are three general reasons to use a conditional.
  2244. * A program may need to use different code depending on the machine
  2245. or operating system it is to run on. In some cases the code for
  2246. one operating system may be erroneous on another operating system;
  2247. for example, it might refer to data types or constants that do not
  2248. exist on the other system. When this happens, it is not enough to
  2249. avoid executing the invalid code. Its mere presence will cause the
  2250. compiler to reject the program. With a preprocessing conditional,
  2251. the offending code can be effectively excised from the program when
  2252. it is not valid.
  2253. * You may want to be able to compile the same source file into two
  2254. different programs. One version might make frequent time-consuming
  2255. consistency checks on its intermediate data, or print the values of
  2256. those data for debugging, and the other not.
  2257. * A conditional whose condition is always false is one way to exclude
  2258. code from the program but keep it as a sort of comment for future
  2259. reference.
  2260. Simple programs that do not need system-specific logic or complex
  2261. debugging hooks generally will not need to use preprocessing
  2262. conditionals.
  2263. 
  2264. File: cpp.info, Node: Conditional Syntax, Next: Deleted Code, Prev: Conditional Uses, Up: Conditionals
  2265. 4.2 Conditional Syntax
  2266. ======================
  2267. A conditional in the C preprocessor begins with a "conditional
  2268. directive": '#if', '#ifdef' or '#ifndef'.
  2269. * Menu:
  2270. * Ifdef::
  2271. * If::
  2272. * Defined::
  2273. * Else::
  2274. * Elif::
  2275. 
  2276. File: cpp.info, Node: Ifdef, Next: If, Up: Conditional Syntax
  2277. 4.2.1 Ifdef
  2278. -----------
  2279. The simplest sort of conditional is
  2280. #ifdef MACRO
  2281. CONTROLLED TEXT
  2282. #endif /* MACRO */
  2283. This block is called a "conditional group". CONTROLLED TEXT will be
  2284. included in the output of the preprocessor if and only if MACRO is
  2285. defined. We say that the conditional "succeeds" if MACRO is defined,
  2286. "fails" if it is not.
  2287. The CONTROLLED TEXT inside of a conditional can include preprocessing
  2288. directives. They are executed only if the conditional succeeds. You
  2289. can nest conditional groups inside other conditional groups, but they
  2290. must be completely nested. In other words, '#endif' always matches the
  2291. nearest '#ifdef' (or '#ifndef', or '#if'). Also, you cannot start a
  2292. conditional group in one file and end it in another.
  2293. Even if a conditional fails, the CONTROLLED TEXT inside it is still
  2294. run through initial transformations and tokenization. Therefore, it
  2295. must all be lexically valid C. Normally the only way this matters is
  2296. that all comments and string literals inside a failing conditional group
  2297. must still be properly ended.
  2298. The comment following the '#endif' is not required, but it is a good
  2299. practice if there is a lot of CONTROLLED TEXT, because it helps people
  2300. match the '#endif' to the corresponding '#ifdef'. Older programs
  2301. sometimes put MACRO directly after the '#endif' without enclosing it in
  2302. a comment. This is invalid code according to the C standard. CPP
  2303. accepts it with a warning. It never affects which '#ifndef' the
  2304. '#endif' matches.
  2305. Sometimes you wish to use some code if a macro is _not_ defined. You
  2306. can do this by writing '#ifndef' instead of '#ifdef'. One common use of
  2307. '#ifndef' is to include code only the first time a header file is
  2308. included. *Note Once-Only Headers::.
  2309. Macro definitions can vary between compilations for several reasons.
  2310. Here are some samples.
  2311. * Some macros are predefined on each kind of machine (*note
  2312. System-specific Predefined Macros::). This allows you to provide
  2313. code specially tuned for a particular machine.
  2314. * System header files define more macros, associated with the
  2315. features they implement. You can test these macros with
  2316. conditionals to avoid using a system feature on a machine where it
  2317. is not implemented.
  2318. * Macros can be defined or undefined with the '-D' and '-U'
  2319. command-line options when you compile the program. You can arrange
  2320. to compile the same source file into two different programs by
  2321. choosing a macro name to specify which program you want, writing
  2322. conditionals to test whether or how this macro is defined, and then
  2323. controlling the state of the macro with command-line options,
  2324. perhaps set in the Makefile. *Note Invocation::.
  2325. * Your program might have a special header file (often called
  2326. 'config.h') that is adjusted when the program is compiled. It can
  2327. define or not define macros depending on the features of the system
  2328. and the desired capabilities of the program. The adjustment can be
  2329. automated by a tool such as 'autoconf', or done by hand.
  2330. 
  2331. File: cpp.info, Node: If, Next: Defined, Prev: Ifdef, Up: Conditional Syntax
  2332. 4.2.2 If
  2333. --------
  2334. The '#if' directive allows you to test the value of an arithmetic
  2335. expression, rather than the mere existence of one macro. Its syntax is
  2336. #if EXPRESSION
  2337. CONTROLLED TEXT
  2338. #endif /* EXPRESSION */
  2339. EXPRESSION is a C expression of integer type, subject to stringent
  2340. restrictions. It may contain
  2341. * Integer constants.
  2342. * Character constants, which are interpreted as they would be in
  2343. normal code.
  2344. * Arithmetic operators for addition, subtraction, multiplication,
  2345. division, bitwise operations, shifts, comparisons, and logical
  2346. operations ('&&' and '||'). The latter two obey the usual
  2347. short-circuiting rules of standard C.
  2348. * Macros. All macros in the expression are expanded before actual
  2349. computation of the expression's value begins.
  2350. * Uses of the 'defined' operator, which lets you check whether macros
  2351. are defined in the middle of an '#if'.
  2352. * Identifiers that are not macros, which are all considered to be the
  2353. number zero. This allows you to write '#if MACRO' instead of
  2354. '#ifdef MACRO', if you know that MACRO, when defined, will always
  2355. have a nonzero value. Function-like macros used without their
  2356. function call parentheses are also treated as zero.
  2357. In some contexts this shortcut is undesirable. The '-Wundef'
  2358. option causes GCC to warn whenever it encounters an identifier
  2359. which is not a macro in an '#if'.
  2360. The preprocessor does not know anything about types in the language.
  2361. Therefore, 'sizeof' operators are not recognized in '#if', and neither
  2362. are 'enum' constants. They will be taken as identifiers which are not
  2363. macros, and replaced by zero. In the case of 'sizeof', this is likely
  2364. to cause the expression to be invalid.
  2365. The preprocessor calculates the value of EXPRESSION. It carries out
  2366. all calculations in the widest integer type known to the compiler; on
  2367. most machines supported by GCC this is 64 bits. This is not the same
  2368. rule as the compiler uses to calculate the value of a constant
  2369. expression, and may give different results in some cases. If the value
  2370. comes out to be nonzero, the '#if' succeeds and the CONTROLLED TEXT is
  2371. included; otherwise it is skipped.
  2372. 
  2373. File: cpp.info, Node: Defined, Next: Else, Prev: If, Up: Conditional Syntax
  2374. 4.2.3 Defined
  2375. -------------
  2376. The special operator 'defined' is used in '#if' and '#elif' expressions
  2377. to test whether a certain name is defined as a macro. 'defined NAME'
  2378. and 'defined (NAME)' are both expressions whose value is 1 if NAME is
  2379. defined as a macro at the current point in the program, and 0 otherwise.
  2380. Thus, '#if defined MACRO' is precisely equivalent to '#ifdef MACRO'.
  2381. 'defined' is useful when you wish to test more than one macro for
  2382. existence at once. For example,
  2383. #if defined (__vax__) || defined (__ns16000__)
  2384. would succeed if either of the names '__vax__' or '__ns16000__' is
  2385. defined as a macro.
  2386. Conditionals written like this:
  2387. #if defined BUFSIZE && BUFSIZE >= 1024
  2388. can generally be simplified to just '#if BUFSIZE >= 1024', since if
  2389. 'BUFSIZE' is not defined, it will be interpreted as having the value
  2390. zero.
  2391. If the 'defined' operator appears as a result of a macro expansion,
  2392. the C standard says the behavior is undefined. GNU cpp treats it as a
  2393. genuine 'defined' operator and evaluates it normally. It will warn
  2394. wherever your code uses this feature if you use the command-line option
  2395. '-Wpedantic', since other compilers may handle it differently. The
  2396. warning is also enabled by '-Wextra', and can also be enabled
  2397. individually with '-Wexpansion-to-defined'.
  2398. 
  2399. File: cpp.info, Node: Else, Next: Elif, Prev: Defined, Up: Conditional Syntax
  2400. 4.2.4 Else
  2401. ----------
  2402. The '#else' directive can be added to a conditional to provide
  2403. alternative text to be used if the condition fails. This is what it
  2404. looks like:
  2405. #if EXPRESSION
  2406. TEXT-IF-TRUE
  2407. #else /* Not EXPRESSION */
  2408. TEXT-IF-FALSE
  2409. #endif /* Not EXPRESSION */
  2410. If EXPRESSION is nonzero, the TEXT-IF-TRUE is included and the
  2411. TEXT-IF-FALSE is skipped. If EXPRESSION is zero, the opposite happens.
  2412. You can use '#else' with '#ifdef' and '#ifndef', too.
  2413. 
  2414. File: cpp.info, Node: Elif, Prev: Else, Up: Conditional Syntax
  2415. 4.2.5 Elif
  2416. ----------
  2417. One common case of nested conditionals is used to check for more than
  2418. two possible alternatives. For example, you might have
  2419. #if X == 1
  2420. ...
  2421. #else /* X != 1 */
  2422. #if X == 2
  2423. ...
  2424. #else /* X != 2 */
  2425. ...
  2426. #endif /* X != 2 */
  2427. #endif /* X != 1 */
  2428. Another conditional directive, '#elif', allows this to be abbreviated
  2429. as follows:
  2430. #if X == 1
  2431. ...
  2432. #elif X == 2
  2433. ...
  2434. #else /* X != 2 and X != 1*/
  2435. ...
  2436. #endif /* X != 2 and X != 1*/
  2437. '#elif' stands for "else if". Like '#else', it goes in the middle of
  2438. a conditional group and subdivides it; it does not require a matching
  2439. '#endif' of its own. Like '#if', the '#elif' directive includes an
  2440. expression to be tested. The text following the '#elif' is processed
  2441. only if the original '#if'-condition failed and the '#elif' condition
  2442. succeeds.
  2443. More than one '#elif' can go in the same conditional group. Then the
  2444. text after each '#elif' is processed only if the '#elif' condition
  2445. succeeds after the original '#if' and all previous '#elif' directives
  2446. within it have failed.
  2447. '#else' is allowed after any number of '#elif' directives, but
  2448. '#elif' may not follow '#else'.
  2449. 
  2450. File: cpp.info, Node: Deleted Code, Prev: Conditional Syntax, Up: Conditionals
  2451. 4.3 Deleted Code
  2452. ================
  2453. If you replace or delete a part of the program but want to keep the old
  2454. code around for future reference, you often cannot simply comment it
  2455. out. Block comments do not nest, so the first comment inside the old
  2456. code will end the commenting-out. The probable result is a flood of
  2457. syntax errors.
  2458. One way to avoid this problem is to use an always-false conditional
  2459. instead. For instance, put '#if 0' before the deleted code and '#endif'
  2460. after it. This works even if the code being turned off contains
  2461. conditionals, but they must be entire conditionals (balanced '#if' and
  2462. '#endif').
  2463. Some people use '#ifdef notdef' instead. This is risky, because
  2464. 'notdef' might be accidentally defined as a macro, and then the
  2465. conditional would succeed. '#if 0' can be counted on to fail.
  2466. Do not use '#if 0' for comments which are not C code. Use a real
  2467. comment, instead. The interior of '#if 0' must consist of complete
  2468. tokens; in particular, single-quote characters must balance. Comments
  2469. often contain unbalanced single-quote characters (known in English as
  2470. apostrophes). These confuse '#if 0'. They don't confuse '/*'.
  2471. 
  2472. File: cpp.info, Node: Diagnostics, Next: Line Control, Prev: Conditionals, Up: Top
  2473. 5 Diagnostics
  2474. *************
  2475. The directive '#error' causes the preprocessor to report a fatal error.
  2476. The tokens forming the rest of the line following '#error' are used as
  2477. the error message.
  2478. You would use '#error' inside of a conditional that detects a
  2479. combination of parameters which you know the program does not properly
  2480. support. For example, if you know that the program will not run
  2481. properly on a VAX, you might write
  2482. #ifdef __vax__
  2483. #error "Won't work on VAXen. See comments at get_last_object."
  2484. #endif
  2485. If you have several configuration parameters that must be set up by
  2486. the installation in a consistent way, you can use conditionals to detect
  2487. an inconsistency and report it with '#error'. For example,
  2488. #if !defined(FOO) && defined(BAR)
  2489. #error "BAR requires FOO."
  2490. #endif
  2491. The directive '#warning' is like '#error', but causes the
  2492. preprocessor to issue a warning and continue preprocessing. The tokens
  2493. following '#warning' are used as the warning message.
  2494. You might use '#warning' in obsolete header files, with a message
  2495. directing the user to the header file which should be used instead.
  2496. Neither '#error' nor '#warning' macro-expands its argument. Internal
  2497. whitespace sequences are each replaced with a single space. The line
  2498. must consist of complete tokens. It is wisest to make the argument of
  2499. these directives be a single string constant; this avoids problems with
  2500. apostrophes and the like.
  2501. 
  2502. File: cpp.info, Node: Line Control, Next: Pragmas, Prev: Diagnostics, Up: Top
  2503. 6 Line Control
  2504. **************
  2505. The C preprocessor informs the C compiler of the location in your source
  2506. code where each token came from. Presently, this is just the file name
  2507. and line number. All the tokens resulting from macro expansion are
  2508. reported as having appeared on the line of the source file where the
  2509. outermost macro was used. We intend to be more accurate in the future.
  2510. If you write a program which generates source code, such as the
  2511. 'bison' parser generator, you may want to adjust the preprocessor's
  2512. notion of the current file name and line number by hand. Parts of the
  2513. output from 'bison' are generated from scratch, other parts come from a
  2514. standard parser file. The rest are copied verbatim from 'bison''s
  2515. input. You would like compiler error messages and symbolic debuggers to
  2516. be able to refer to 'bison''s input file.
  2517. 'bison' or any such program can arrange this by writing '#line'
  2518. directives into the output file. '#line' is a directive that specifies
  2519. the original line number and source file name for subsequent input in
  2520. the current preprocessor input file. '#line' has three variants:
  2521. '#line LINENUM'
  2522. LINENUM is a non-negative decimal integer constant. It specifies
  2523. the line number which should be reported for the following line of
  2524. input. Subsequent lines are counted from LINENUM.
  2525. '#line LINENUM FILENAME'
  2526. LINENUM is the same as for the first form, and has the same effect.
  2527. In addition, FILENAME is a string constant. The following line and
  2528. all subsequent lines are reported to come from the file it
  2529. specifies, until something else happens to change that. FILENAME
  2530. is interpreted according to the normal rules for a string constant:
  2531. backslash escapes are interpreted. This is different from
  2532. '#include'.
  2533. '#line ANYTHING ELSE'
  2534. ANYTHING ELSE is checked for macro calls, which are expanded. The
  2535. result should match one of the above two forms.
  2536. '#line' directives alter the results of the '__FILE__' and '__LINE__'
  2537. predefined macros from that point on. *Note Standard Predefined
  2538. Macros::. They do not have any effect on '#include''s idea of the
  2539. directory containing the current file.
  2540. 
  2541. File: cpp.info, Node: Pragmas, Next: Other Directives, Prev: Line Control, Up: Top
  2542. 7 Pragmas
  2543. *********
  2544. The '#pragma' directive is the method specified by the C standard for
  2545. providing additional information to the compiler, beyond what is
  2546. conveyed in the language itself. The forms of this directive (commonly
  2547. known as "pragmas") specified by C standard are prefixed with 'STDC'. A
  2548. C compiler is free to attach any meaning it likes to other pragmas. All
  2549. GNU-defined, supported pragmas have been given a 'GCC' prefix.
  2550. C99 introduced the '_Pragma' operator. This feature addresses a
  2551. major problem with '#pragma': being a directive, it cannot be produced
  2552. as the result of macro expansion. '_Pragma' is an operator, much like
  2553. 'sizeof' or 'defined', and can be embedded in a macro.
  2554. Its syntax is '_Pragma (STRING-LITERAL)', where STRING-LITERAL can be
  2555. either a normal or wide-character string literal. It is destringized,
  2556. by replacing all '\\' with a single '\' and all '\"' with a '"'. The
  2557. result is then processed as if it had appeared as the right hand side of
  2558. a '#pragma' directive. For example,
  2559. _Pragma ("GCC dependency \"parse.y\"")
  2560. has the same effect as '#pragma GCC dependency "parse.y"'. The same
  2561. effect could be achieved using macros, for example
  2562. #define DO_PRAGMA(x) _Pragma (#x)
  2563. DO_PRAGMA (GCC dependency "parse.y")
  2564. The standard is unclear on where a '_Pragma' operator can appear.
  2565. The preprocessor does not accept it within a preprocessing conditional
  2566. directive like '#if'. To be safe, you are probably best keeping it out
  2567. of directives other than '#define', and putting it on a line of its own.
  2568. This manual documents the pragmas which are meaningful to the
  2569. preprocessor itself. Other pragmas are meaningful to the C or C++
  2570. compilers. They are documented in the GCC manual.
  2571. GCC plugins may provide their own pragmas.
  2572. '#pragma GCC dependency'
  2573. '#pragma GCC dependency' allows you to check the relative dates of
  2574. the current file and another file. If the other file is more
  2575. recent than the current file, a warning is issued. This is useful
  2576. if the current file is derived from the other file, and should be
  2577. regenerated. The other file is searched for using the normal
  2578. include search path. Optional trailing text can be used to give
  2579. more information in the warning message.
  2580. #pragma GCC dependency "parse.y"
  2581. #pragma GCC dependency "/usr/include/time.h" rerun fixincludes
  2582. '#pragma GCC poison'
  2583. Sometimes, there is an identifier that you want to remove
  2584. completely from your program, and make sure that it never creeps
  2585. back in. To enforce this, you can "poison" the identifier with
  2586. this pragma. '#pragma GCC poison' is followed by a list of
  2587. identifiers to poison. If any of those identifiers appears
  2588. anywhere in the source after the directive, it is a hard error.
  2589. For example,
  2590. #pragma GCC poison printf sprintf fprintf
  2591. sprintf(some_string, "hello");
  2592. will produce an error.
  2593. If a poisoned identifier appears as part of the expansion of a
  2594. macro which was defined before the identifier was poisoned, it will
  2595. _not_ cause an error. This lets you poison an identifier without
  2596. worrying about system headers defining macros that use it.
  2597. For example,
  2598. #define strrchr rindex
  2599. #pragma GCC poison rindex
  2600. strrchr(some_string, 'h');
  2601. will not produce an error.
  2602. '#pragma GCC system_header'
  2603. This pragma takes no arguments. It causes the rest of the code in
  2604. the current file to be treated as if it came from a system header.
  2605. *Note System Headers::.
  2606. '#pragma GCC warning'
  2607. '#pragma GCC error'
  2608. '#pragma GCC warning "message"' causes the preprocessor to issue a
  2609. warning diagnostic with the text 'message'. The message contained
  2610. in the pragma must be a single string literal. Similarly, '#pragma
  2611. GCC error "message"' issues an error message. Unlike the
  2612. '#warning' and '#error' directives, these pragmas can be embedded
  2613. in preprocessor macros using '_Pragma'.
  2614. 
  2615. File: cpp.info, Node: Other Directives, Next: Preprocessor Output, Prev: Pragmas, Up: Top
  2616. 8 Other Directives
  2617. ******************
  2618. The '#ident' directive takes one argument, a string constant. On some
  2619. systems, that string constant is copied into a special segment of the
  2620. object file. On other systems, the directive is ignored. The '#sccs'
  2621. directive is a synonym for '#ident'.
  2622. These directives are not part of the C standard, but they are not
  2623. official GNU extensions either. What historical information we have
  2624. been able to find, suggests they originated with System V.
  2625. The "null directive" consists of a '#' followed by a newline, with
  2626. only whitespace (including comments) in between. A null directive is
  2627. understood as a preprocessing directive but has no effect on the
  2628. preprocessor output. The primary significance of the existence of the
  2629. null directive is that an input line consisting of just a '#' will
  2630. produce no output, rather than a line of output containing just a '#'.
  2631. Supposedly some old C programs contain such lines.
  2632. 
  2633. File: cpp.info, Node: Preprocessor Output, Next: Traditional Mode, Prev: Other Directives, Up: Top
  2634. 9 Preprocessor Output
  2635. *********************
  2636. When the C preprocessor is used with the C, C++, or Objective-C
  2637. compilers, it is integrated into the compiler and communicates a stream
  2638. of binary tokens directly to the compiler's parser. However, it can
  2639. also be used in the more conventional standalone mode, where it produces
  2640. textual output.
  2641. The output from the C preprocessor looks much like the input, except
  2642. that all preprocessing directive lines have been replaced with blank
  2643. lines and all comments with spaces. Long runs of blank lines are
  2644. discarded.
  2645. The ISO standard specifies that it is implementation defined whether
  2646. a preprocessor preserves whitespace between tokens, or replaces it with
  2647. e.g. a single space. In GNU CPP, whitespace between tokens is collapsed
  2648. to become a single space, with the exception that the first token on a
  2649. non-directive line is preceded with sufficient spaces that it appears in
  2650. the same column in the preprocessed output that it appeared in the
  2651. original source file. This is so the output is easy to read. CPP does
  2652. not insert any whitespace where there was none in the original source,
  2653. except where necessary to prevent an accidental token paste.
  2654. Source file name and line number information is conveyed by lines of
  2655. the form
  2656. # LINENUM FILENAME FLAGS
  2657. These are called "linemarkers". They are inserted as needed into the
  2658. output (but never within a string or character constant). They mean
  2659. that the following line originated in file FILENAME at line LINENUM.
  2660. FILENAME will never contain any non-printing characters; they are
  2661. replaced with octal escape sequences.
  2662. After the file name comes zero or more flags, which are '1', '2',
  2663. '3', or '4'. If there are multiple flags, spaces separate them. Here
  2664. is what the flags mean:
  2665. '1'
  2666. This indicates the start of a new file.
  2667. '2'
  2668. This indicates returning to a file (after having included another
  2669. file).
  2670. '3'
  2671. This indicates that the following text comes from a system header
  2672. file, so certain warnings should be suppressed.
  2673. '4'
  2674. This indicates that the following text should be treated as being
  2675. wrapped in an implicit 'extern "C"' block.
  2676. As an extension, the preprocessor accepts linemarkers in
  2677. non-assembler input files. They are treated like the corresponding
  2678. '#line' directive, (*note Line Control::), except that trailing flags
  2679. are permitted, and are interpreted with the meanings described above.
  2680. If multiple flags are given, they must be in ascending order.
  2681. Some directives may be duplicated in the output of the preprocessor.
  2682. These are '#ident' (always), '#pragma' (only if the preprocessor does
  2683. not handle the pragma itself), and '#define' and '#undef' (with certain
  2684. debugging options). If this happens, the '#' of the directive will
  2685. always be in the first column, and there will be no space between the
  2686. '#' and the directive name. If macro expansion happens to generate
  2687. tokens which might be mistaken for a duplicated directive, a space will
  2688. be inserted between the '#' and the directive name.
  2689. 
  2690. File: cpp.info, Node: Traditional Mode, Next: Implementation Details, Prev: Preprocessor Output, Up: Top
  2691. 10 Traditional Mode
  2692. *******************
  2693. Traditional (pre-standard) C preprocessing is rather different from the
  2694. preprocessing specified by the standard. When the preprocessor is
  2695. invoked with the '-traditional-cpp' option, it attempts to emulate a
  2696. traditional preprocessor.
  2697. This mode is not useful for compiling C code with GCC, but is
  2698. intended for use with non-C preprocessing applications. Thus
  2699. traditional mode semantics are supported only when invoking the
  2700. preprocessor explicitly, and not in the compiler front ends.
  2701. The implementation does not correspond precisely to the behavior of
  2702. early pre-standard versions of GCC, nor to any true traditional
  2703. preprocessor. After all, inconsistencies among traditional
  2704. implementations were a major motivation for C standardization. However,
  2705. we intend that it should be compatible with true traditional
  2706. preprocessors in all ways that actually matter.
  2707. * Menu:
  2708. * Traditional lexical analysis::
  2709. * Traditional macros::
  2710. * Traditional miscellany::
  2711. * Traditional warnings::
  2712. 
  2713. File: cpp.info, Node: Traditional lexical analysis, Next: Traditional macros, Up: Traditional Mode
  2714. 10.1 Traditional lexical analysis
  2715. =================================
  2716. The traditional preprocessor does not decompose its input into tokens
  2717. the same way a standards-conforming preprocessor does. The input is
  2718. simply treated as a stream of text with minimal internal form.
  2719. This implementation does not treat trigraphs (*note trigraphs::)
  2720. specially since they were an invention of the standards committee. It
  2721. handles arbitrarily-positioned escaped newlines properly and splices the
  2722. lines as you would expect; many traditional preprocessors did not do
  2723. this.
  2724. The form of horizontal whitespace in the input file is preserved in
  2725. the output. In particular, hard tabs remain hard tabs. This can be
  2726. useful if, for example, you are preprocessing a Makefile.
  2727. Traditional CPP only recognizes C-style block comments, and treats
  2728. the '/*' sequence as introducing a comment only if it lies outside
  2729. quoted text. Quoted text is introduced by the usual single and double
  2730. quotes, and also by an initial '<' in a '#include' directive.
  2731. Traditionally, comments are completely removed and are not replaced
  2732. with a space. Since a traditional compiler does its own tokenization of
  2733. the output of the preprocessor, this means that comments can effectively
  2734. be used as token paste operators. However, comments behave like
  2735. separators for text handled by the preprocessor itself, since it doesn't
  2736. re-lex its input. For example, in
  2737. #if foo/**/bar
  2738. 'foo' and 'bar' are distinct identifiers and expanded separately if they
  2739. happen to be macros. In other words, this directive is equivalent to
  2740. #if foo bar
  2741. rather than
  2742. #if foobar
  2743. Generally speaking, in traditional mode an opening quote need not
  2744. have a matching closing quote. In particular, a macro may be defined
  2745. with replacement text that contains an unmatched quote. Of course, if
  2746. you attempt to compile preprocessed output containing an unmatched quote
  2747. you will get a syntax error.
  2748. However, all preprocessing directives other than '#define' require
  2749. matching quotes. For example:
  2750. #define m This macro's fine and has an unmatched quote
  2751. "/* This is not a comment. */
  2752. /* This is a comment. The following #include directive
  2753. is ill-formed. */
  2754. #include <stdio.h
  2755. Just as for the ISO preprocessor, what would be a closing quote can
  2756. be escaped with a backslash to prevent the quoted text from closing.
  2757. 
  2758. File: cpp.info, Node: Traditional macros, Next: Traditional miscellany, Prev: Traditional lexical analysis, Up: Traditional Mode
  2759. 10.2 Traditional macros
  2760. =======================
  2761. The major difference between traditional and ISO macros is that the
  2762. former expand to text rather than to a token sequence. CPP removes all
  2763. leading and trailing horizontal whitespace from a macro's replacement
  2764. text before storing it, but preserves the form of internal whitespace.
  2765. One consequence is that it is legitimate for the replacement text to
  2766. contain an unmatched quote (*note Traditional lexical analysis::). An
  2767. unclosed string or character constant continues into the text following
  2768. the macro call. Similarly, the text at the end of a macro's expansion
  2769. can run together with the text after the macro invocation to produce a
  2770. single token.
  2771. Normally comments are removed from the replacement text after the
  2772. macro is expanded, but if the '-CC' option is passed on the command-line
  2773. comments are preserved. (In fact, the current implementation removes
  2774. comments even before saving the macro replacement text, but it careful
  2775. to do it in such a way that the observed effect is identical even in the
  2776. function-like macro case.)
  2777. The ISO stringizing operator '#' and token paste operator '##' have
  2778. no special meaning. As explained later, an effect similar to these
  2779. operators can be obtained in a different way. Macro names that are
  2780. embedded in quotes, either from the main file or after macro
  2781. replacement, do not expand.
  2782. CPP replaces an unquoted object-like macro name with its replacement
  2783. text, and then rescans it for further macros to replace. Unlike
  2784. standard macro expansion, traditional macro expansion has no provision
  2785. to prevent recursion. If an object-like macro appears unquoted in its
  2786. replacement text, it will be replaced again during the rescan pass, and
  2787. so on _ad infinitum_. GCC detects when it is expanding recursive
  2788. macros, emits an error message, and continues after the offending macro
  2789. invocation.
  2790. #define PLUS +
  2791. #define INC(x) PLUS+x
  2792. INC(foo);
  2793. ==> ++foo;
  2794. Function-like macros are similar in form but quite different in
  2795. behavior to their ISO counterparts. Their arguments are contained
  2796. within parentheses, are comma-separated, and can cross physical lines.
  2797. Commas within nested parentheses are not treated as argument separators.
  2798. Similarly, a quote in an argument cannot be left unclosed; a following
  2799. comma or parenthesis that comes before the closing quote is treated like
  2800. any other character. There is no facility for handling variadic macros.
  2801. This implementation removes all comments from macro arguments, unless
  2802. the '-C' option is given. The form of all other horizontal whitespace
  2803. in arguments is preserved, including leading and trailing whitespace.
  2804. In particular
  2805. f( )
  2806. is treated as an invocation of the macro 'f' with a single argument
  2807. consisting of a single space. If you want to invoke a function-like
  2808. macro that takes no arguments, you must not leave any whitespace between
  2809. the parentheses.
  2810. If a macro argument crosses a new line, the new line is replaced with
  2811. a space when forming the argument. If the previous line contained an
  2812. unterminated quote, the following line inherits the quoted state.
  2813. Traditional preprocessors replace parameters in the replacement text
  2814. with their arguments regardless of whether the parameters are within
  2815. quotes or not. This provides a way to stringize arguments. For example
  2816. #define str(x) "x"
  2817. str(/* A comment */some text )
  2818. ==> "some text "
  2819. Note that the comment is removed, but that the trailing space is
  2820. preserved. Here is an example of using a comment to effect token
  2821. pasting.
  2822. #define suffix(x) foo_/**/x
  2823. suffix(bar)
  2824. ==> foo_bar
  2825. 
  2826. File: cpp.info, Node: Traditional miscellany, Next: Traditional warnings, Prev: Traditional macros, Up: Traditional Mode
  2827. 10.3 Traditional miscellany
  2828. ===========================
  2829. Here are some things to be aware of when using the traditional
  2830. preprocessor.
  2831. * Preprocessing directives are recognized only when their leading '#'
  2832. appears in the first column. There can be no whitespace between
  2833. the beginning of the line and the '#', but whitespace can follow
  2834. the '#'.
  2835. * A true traditional C preprocessor does not recognize '#error' or
  2836. '#pragma', and may not recognize '#elif'. CPP supports all the
  2837. directives in traditional mode that it supports in ISO mode,
  2838. including extensions, with the exception that the effects of
  2839. '#pragma GCC poison' are undefined.
  2840. * __STDC__ is not defined.
  2841. * If you use digraphs the behavior is undefined.
  2842. * If a line that looks like a directive appears within macro
  2843. arguments, the behavior is undefined.
  2844. 
  2845. File: cpp.info, Node: Traditional warnings, Prev: Traditional miscellany, Up: Traditional Mode
  2846. 10.4 Traditional warnings
  2847. =========================
  2848. You can request warnings about features that did not exist, or worked
  2849. differently, in traditional C with the '-Wtraditional' option. GCC does
  2850. not warn about features of ISO C which you must use when you are using a
  2851. conforming compiler, such as the '#' and '##' operators.
  2852. Presently '-Wtraditional' warns about:
  2853. * Macro parameters that appear within string literals in the macro
  2854. body. In traditional C macro replacement takes place within string
  2855. literals, but does not in ISO C.
  2856. * In traditional C, some preprocessor directives did not exist.
  2857. Traditional preprocessors would only consider a line to be a
  2858. directive if the '#' appeared in column 1 on the line. Therefore
  2859. '-Wtraditional' warns about directives that traditional C
  2860. understands but would ignore because the '#' does not appear as the
  2861. first character on the line. It also suggests you hide directives
  2862. like '#pragma' not understood by traditional C by indenting them.
  2863. Some traditional implementations would not recognize '#elif', so it
  2864. suggests avoiding it altogether.
  2865. * A function-like macro that appears without an argument list. In
  2866. some traditional preprocessors this was an error. In ISO C it
  2867. merely means that the macro is not expanded.
  2868. * The unary plus operator. This did not exist in traditional C.
  2869. * The 'U' and 'LL' integer constant suffixes, which were not
  2870. available in traditional C. (Traditional C does support the 'L'
  2871. suffix for simple long integer constants.) You are not warned
  2872. about uses of these suffixes in macros defined in system headers.
  2873. For instance, 'UINT_MAX' may well be defined as '4294967295U', but
  2874. you will not be warned if you use 'UINT_MAX'.
  2875. You can usually avoid the warning, and the related warning about
  2876. constants which are so large that they are unsigned, by writing the
  2877. integer constant in question in hexadecimal, with no U suffix.
  2878. Take care, though, because this gives the wrong result in exotic
  2879. cases.
  2880. 
  2881. File: cpp.info, Node: Implementation Details, Next: Invocation, Prev: Traditional Mode, Up: Top
  2882. 11 Implementation Details
  2883. *************************
  2884. Here we document details of how the preprocessor's implementation
  2885. affects its user-visible behavior. You should try to avoid undue
  2886. reliance on behavior described here, as it is possible that it will
  2887. change subtly in future implementations.
  2888. Also documented here are obsolete features still supported by CPP.
  2889. * Menu:
  2890. * Implementation-defined behavior::
  2891. * Implementation limits::
  2892. * Obsolete Features::
  2893. 
  2894. File: cpp.info, Node: Implementation-defined behavior, Next: Implementation limits, Up: Implementation Details
  2895. 11.1 Implementation-defined behavior
  2896. ====================================
  2897. This is how CPP behaves in all the cases which the C standard describes
  2898. as "implementation-defined". This term means that the implementation is
  2899. free to do what it likes, but must document its choice and stick to it.
  2900. * The mapping of physical source file multi-byte characters to the
  2901. execution character set.
  2902. The input character set can be specified using the
  2903. '-finput-charset' option, while the execution character set may be
  2904. controlled using the '-fexec-charset' and '-fwide-exec-charset'
  2905. options.
  2906. * Identifier characters.
  2907. The C and C++ standards allow identifiers to be composed of '_' and
  2908. the alphanumeric characters. C++ also allows universal character
  2909. names. C99 and later C standards permit both universal character
  2910. names and implementation-defined characters.
  2911. GCC allows the '$' character in identifiers as an extension for
  2912. most targets. This is true regardless of the 'std=' switch, since
  2913. this extension cannot conflict with standards-conforming programs.
  2914. When preprocessing assembler, however, dollars are not identifier
  2915. characters by default.
  2916. Currently the targets that by default do not permit '$' are AVR,
  2917. IP2K, MMIX, MIPS Irix 3, ARM aout, and PowerPC targets for the AIX
  2918. operating system.
  2919. You can override the default with '-fdollars-in-identifiers' or
  2920. 'fno-dollars-in-identifiers'. *Note fdollars-in-identifiers::.
  2921. * Non-empty sequences of whitespace characters.
  2922. In textual output, each whitespace sequence is collapsed to a
  2923. single space. For aesthetic reasons, the first token on each
  2924. non-directive line of output is preceded with sufficient spaces
  2925. that it appears in the same column as it did in the original source
  2926. file.
  2927. * The numeric value of character constants in preprocessor
  2928. expressions.
  2929. The preprocessor and compiler interpret character constants in the
  2930. same way; i.e. escape sequences such as '\a' are given the values
  2931. they would have on the target machine.
  2932. The compiler evaluates a multi-character character constant a
  2933. character at a time, shifting the previous value left by the number
  2934. of bits per target character, and then or-ing in the bit-pattern of
  2935. the new character truncated to the width of a target character.
  2936. The final bit-pattern is given type 'int', and is therefore signed,
  2937. regardless of whether single characters are signed or not. If
  2938. there are more characters in the constant than would fit in the
  2939. target 'int' the compiler issues a warning, and the excess leading
  2940. characters are ignored.
  2941. For example, ''ab'' for a target with an 8-bit 'char' would be
  2942. interpreted as
  2943. '(int) ((unsigned char) 'a' * 256 + (unsigned char) 'b')', and
  2944. ''\234a'' as
  2945. '(int) ((unsigned char) '\234' * 256 + (unsigned char) 'a')'.
  2946. * Source file inclusion.
  2947. For a discussion on how the preprocessor locates header files,
  2948. *note Include Operation::.
  2949. * Interpretation of the filename resulting from a macro-expanded
  2950. '#include' directive.
  2951. *Note Computed Includes::.
  2952. * Treatment of a '#pragma' directive that after macro-expansion
  2953. results in a standard pragma.
  2954. No macro expansion occurs on any '#pragma' directive line, so the
  2955. question does not arise.
  2956. Note that GCC does not yet implement any of the standard pragmas.
  2957. 
  2958. File: cpp.info, Node: Implementation limits, Next: Obsolete Features, Prev: Implementation-defined behavior, Up: Implementation Details
  2959. 11.2 Implementation limits
  2960. ==========================
  2961. CPP has a small number of internal limits. This section lists the
  2962. limits which the C standard requires to be no lower than some minimum,
  2963. and all the others known. It is intended that there should be as few
  2964. limits as possible. If you encounter an undocumented or inconvenient
  2965. limit, please report that as a bug. *Note Reporting Bugs: (gcc)Bugs.
  2966. Where we say something is limited "only by available memory", that
  2967. means that internal data structures impose no intrinsic limit, and space
  2968. is allocated with 'malloc' or equivalent. The actual limit will
  2969. therefore depend on many things, such as the size of other things
  2970. allocated by the compiler at the same time, the amount of memory
  2971. consumed by other processes on the same computer, etc.
  2972. * Nesting levels of '#include' files.
  2973. We impose an arbitrary limit of 200 levels, to avoid runaway
  2974. recursion. The standard requires at least 15 levels.
  2975. * Nesting levels of conditional inclusion.
  2976. The C standard mandates this be at least 63. CPP is limited only
  2977. by available memory.
  2978. * Levels of parenthesized expressions within a full expression.
  2979. The C standard requires this to be at least 63. In preprocessor
  2980. conditional expressions, it is limited only by available memory.
  2981. * Significant initial characters in an identifier or macro name.
  2982. The preprocessor treats all characters as significant. The C
  2983. standard requires only that the first 63 be significant.
  2984. * Number of macros simultaneously defined in a single translation
  2985. unit.
  2986. The standard requires at least 4095 be possible. CPP is limited
  2987. only by available memory.
  2988. * Number of parameters in a macro definition and arguments in a macro
  2989. call.
  2990. We allow 'USHRT_MAX', which is no smaller than 65,535. The minimum
  2991. required by the standard is 127.
  2992. * Number of characters on a logical source line.
  2993. The C standard requires a minimum of 4096 be permitted. CPP places
  2994. no limits on this, but you may get incorrect column numbers
  2995. reported in diagnostics for lines longer than 65,535 characters.
  2996. * Maximum size of a source file.
  2997. The standard does not specify any lower limit on the maximum size
  2998. of a source file. GNU cpp maps files into memory, so it is limited
  2999. by the available address space. This is generally at least two
  3000. gigabytes. Depending on the operating system, the size of physical
  3001. memory may or may not be a limitation.
  3002. 
  3003. File: cpp.info, Node: Obsolete Features, Prev: Implementation limits, Up: Implementation Details
  3004. 11.3 Obsolete Features
  3005. ======================
  3006. CPP has some features which are present mainly for compatibility with
  3007. older programs. We discourage their use in new code. In some cases, we
  3008. plan to remove the feature in a future version of GCC.
  3009. 11.3.1 Assertions
  3010. -----------------
  3011. "Assertions" are a deprecated alternative to macros in writing
  3012. conditionals to test what sort of computer or system the compiled
  3013. program will run on. Assertions are usually predefined, but you can
  3014. define them with preprocessing directives or command-line options.
  3015. Assertions were intended to provide a more systematic way to describe
  3016. the compiler's target system and we added them for compatibility with
  3017. existing compilers. In practice they are just as unpredictable as the
  3018. system-specific predefined macros. In addition, they are not part of
  3019. any standard, and only a few compilers support them. Therefore, the use
  3020. of assertions is *less* portable than the use of system-specific
  3021. predefined macros. We recommend you do not use them at all.
  3022. An assertion looks like this:
  3023. #PREDICATE (ANSWER)
  3024. PREDICATE must be a single identifier. ANSWER can be any sequence of
  3025. tokens; all characters are significant except for leading and trailing
  3026. whitespace, and differences in internal whitespace sequences are
  3027. ignored. (This is similar to the rules governing macro redefinition.)
  3028. Thus, '(x + y)' is different from '(x+y)' but equivalent to '( x + y )'.
  3029. Parentheses do not nest inside an answer.
  3030. To test an assertion, you write it in an '#if'. For example, this
  3031. conditional succeeds if either 'vax' or 'ns16000' has been asserted as
  3032. an answer for 'machine'.
  3033. #if #machine (vax) || #machine (ns16000)
  3034. You can test whether _any_ answer is asserted for a predicate by
  3035. omitting the answer in the conditional:
  3036. #if #machine
  3037. Assertions are made with the '#assert' directive. Its sole argument
  3038. is the assertion to make, without the leading '#' that identifies
  3039. assertions in conditionals.
  3040. #assert PREDICATE (ANSWER)
  3041. You may make several assertions with the same predicate and different
  3042. answers. Subsequent assertions do not override previous ones for the
  3043. same predicate. All the answers for any given predicate are
  3044. simultaneously true.
  3045. Assertions can be canceled with the '#unassert' directive. It has
  3046. the same syntax as '#assert'. In that form it cancels only the answer
  3047. which was specified on the '#unassert' line; other answers for that
  3048. predicate remain true. You can cancel an entire predicate by leaving
  3049. out the answer:
  3050. #unassert PREDICATE
  3051. In either form, if no such assertion has been made, '#unassert' has no
  3052. effect.
  3053. You can also make or cancel assertions using command-line options.
  3054. *Note Invocation::.
  3055. 
  3056. File: cpp.info, Node: Invocation, Next: Environment Variables, Prev: Implementation Details, Up: Top
  3057. 12 Invocation
  3058. *************
  3059. Most often when you use the C preprocessor you do not have to invoke it
  3060. explicitly: the C compiler does so automatically. However, the
  3061. preprocessor is sometimes useful on its own. You can invoke the
  3062. preprocessor either with the 'cpp' command, or via 'gcc -E'. In GCC,
  3063. the preprocessor is actually integrated with the compiler rather than a
  3064. separate program, and both of these commands invoke GCC and tell it to
  3065. stop after the preprocessing phase.
  3066. The 'cpp' options listed here are also accepted by 'gcc' and have the
  3067. same meaning. Likewise the 'cpp' command accepts all the usual 'gcc'
  3068. driver options, although those pertaining to compilation phases after
  3069. preprocessing are ignored.
  3070. Only options specific to preprocessing behavior are documented here.
  3071. Refer to the GCC manual for full documentation of other driver options.
  3072. The 'cpp' command expects two file names as arguments, INFILE and
  3073. OUTFILE. The preprocessor reads INFILE together with any other files it
  3074. specifies with '#include'. All the output generated by the combined
  3075. input files is written in OUTFILE.
  3076. Either INFILE or OUTFILE may be '-', which as INFILE means to read
  3077. from standard input and as OUTFILE means to write to standard output.
  3078. If either file is omitted, it means the same as if '-' had been
  3079. specified for that file. You can also use the '-o OUTFILE' option to
  3080. specify the output file.
  3081. Unless otherwise noted, or the option ends in '=', all options which
  3082. take an argument may have that argument appear either immediately after
  3083. the option, or with a space between option and argument: '-Ifoo' and '-I
  3084. foo' have the same effect.
  3085. Many options have multi-letter names; therefore multiple
  3086. single-letter options may _not_ be grouped: '-dM' is very different from
  3087. '-d -M'.
  3088. '-D NAME'
  3089. Predefine NAME as a macro, with definition '1'.
  3090. '-D NAME=DEFINITION'
  3091. The contents of DEFINITION are tokenized and processed as if they
  3092. appeared during translation phase three in a '#define' directive.
  3093. In particular, the definition is truncated by embedded newline
  3094. characters.
  3095. If you are invoking the preprocessor from a shell or shell-like
  3096. program you may need to use the shell's quoting syntax to protect
  3097. characters such as spaces that have a meaning in the shell syntax.
  3098. If you wish to define a function-like macro on the command line,
  3099. write its argument list with surrounding parentheses before the
  3100. equals sign (if any). Parentheses are meaningful to most shells,
  3101. so you should quote the option. With 'sh' and 'csh',
  3102. '-D'NAME(ARGS...)=DEFINITION'' works.
  3103. '-D' and '-U' options are processed in the order they are given on
  3104. the command line. All '-imacros FILE' and '-include FILE' options
  3105. are processed after all '-D' and '-U' options.
  3106. '-U NAME'
  3107. Cancel any previous definition of NAME, either built in or provided
  3108. with a '-D' option.
  3109. '-include FILE'
  3110. Process FILE as if '#include "file"' appeared as the first line of
  3111. the primary source file. However, the first directory searched for
  3112. FILE is the preprocessor's working directory _instead of_ the
  3113. directory containing the main source file. If not found there, it
  3114. is searched for in the remainder of the '#include "..."' search
  3115. chain as normal.
  3116. If multiple '-include' options are given, the files are included in
  3117. the order they appear on the command line.
  3118. '-imacros FILE'
  3119. Exactly like '-include', except that any output produced by
  3120. scanning FILE is thrown away. Macros it defines remain defined.
  3121. This allows you to acquire all the macros from a header without
  3122. also processing its declarations.
  3123. All files specified by '-imacros' are processed before all files
  3124. specified by '-include'.
  3125. '-undef'
  3126. Do not predefine any system-specific or GCC-specific macros. The
  3127. standard predefined macros remain defined. *Note Standard
  3128. Predefined Macros::.
  3129. '-pthread'
  3130. Define additional macros required for using the POSIX threads
  3131. library. You should use this option consistently for both
  3132. compilation and linking. This option is supported on GNU/Linux
  3133. targets, most other Unix derivatives, and also on x86 Cygwin and
  3134. MinGW targets.
  3135. '-M'
  3136. Instead of outputting the result of preprocessing, output a rule
  3137. suitable for 'make' describing the dependencies of the main source
  3138. file. The preprocessor outputs one 'make' rule containing the
  3139. object file name for that source file, a colon, and the names of
  3140. all the included files, including those coming from '-include' or
  3141. '-imacros' command-line options.
  3142. Unless specified explicitly (with '-MT' or '-MQ'), the object file
  3143. name consists of the name of the source file with any suffix
  3144. replaced with object file suffix and with any leading directory
  3145. parts removed. If there are many included files then the rule is
  3146. split into several lines using '\'-newline. The rule has no
  3147. commands.
  3148. This option does not suppress the preprocessor's debug output, such
  3149. as '-dM'. To avoid mixing such debug output with the dependency
  3150. rules you should explicitly specify the dependency output file with
  3151. '-MF', or use an environment variable like 'DEPENDENCIES_OUTPUT'
  3152. (*note Environment Variables::). Debug output is still sent to the
  3153. regular output stream as normal.
  3154. Passing '-M' to the driver implies '-E', and suppresses warnings
  3155. with an implicit '-w'.
  3156. '-MM'
  3157. Like '-M' but do not mention header files that are found in system
  3158. header directories, nor header files that are included, directly or
  3159. indirectly, from such a header.
  3160. This implies that the choice of angle brackets or double quotes in
  3161. an '#include' directive does not in itself determine whether that
  3162. header appears in '-MM' dependency output.
  3163. '-MF FILE'
  3164. When used with '-M' or '-MM', specifies a file to write the
  3165. dependencies to. If no '-MF' switch is given the preprocessor
  3166. sends the rules to the same place it would send preprocessed
  3167. output.
  3168. When used with the driver options '-MD' or '-MMD', '-MF' overrides
  3169. the default dependency output file.
  3170. If FILE is '-', then the dependencies are written to 'stdout'.
  3171. '-MG'
  3172. In conjunction with an option such as '-M' requesting dependency
  3173. generation, '-MG' assumes missing header files are generated files
  3174. and adds them to the dependency list without raising an error. The
  3175. dependency filename is taken directly from the '#include' directive
  3176. without prepending any path. '-MG' also suppresses preprocessed
  3177. output, as a missing header file renders this useless.
  3178. This feature is used in automatic updating of makefiles.
  3179. '-MP'
  3180. This option instructs CPP to add a phony target for each dependency
  3181. other than the main file, causing each to depend on nothing. These
  3182. dummy rules work around errors 'make' gives if you remove header
  3183. files without updating the 'Makefile' to match.
  3184. This is typical output:
  3185. test.o: test.c test.h
  3186. test.h:
  3187. '-MT TARGET'
  3188. Change the target of the rule emitted by dependency generation. By
  3189. default CPP takes the name of the main input file, deletes any
  3190. directory components and any file suffix such as '.c', and appends
  3191. the platform's usual object suffix. The result is the target.
  3192. An '-MT' option sets the target to be exactly the string you
  3193. specify. If you want multiple targets, you can specify them as a
  3194. single argument to '-MT', or use multiple '-MT' options.
  3195. For example, '-MT '$(objpfx)foo.o'' might give
  3196. $(objpfx)foo.o: foo.c
  3197. '-MQ TARGET'
  3198. Same as '-MT', but it quotes any characters which are special to
  3199. Make. '-MQ '$(objpfx)foo.o'' gives
  3200. $$(objpfx)foo.o: foo.c
  3201. The default target is automatically quoted, as if it were given
  3202. with '-MQ'.
  3203. '-MD'
  3204. '-MD' is equivalent to '-M -MF FILE', except that '-E' is not
  3205. implied. The driver determines FILE based on whether an '-o'
  3206. option is given. If it is, the driver uses its argument but with a
  3207. suffix of '.d', otherwise it takes the name of the input file,
  3208. removes any directory components and suffix, and applies a '.d'
  3209. suffix.
  3210. If '-MD' is used in conjunction with '-E', any '-o' switch is
  3211. understood to specify the dependency output file (*note -MF:
  3212. dashMF.), but if used without '-E', each '-o' is understood to
  3213. specify a target object file.
  3214. Since '-E' is not implied, '-MD' can be used to generate a
  3215. dependency output file as a side effect of the compilation process.
  3216. '-MMD'
  3217. Like '-MD' except mention only user header files, not system header
  3218. files.
  3219. '-fpreprocessed'
  3220. Indicate to the preprocessor that the input file has already been
  3221. preprocessed. This suppresses things like macro expansion,
  3222. trigraph conversion, escaped newline splicing, and processing of
  3223. most directives. The preprocessor still recognizes and removes
  3224. comments, so that you can pass a file preprocessed with '-C' to the
  3225. compiler without problems. In this mode the integrated
  3226. preprocessor is little more than a tokenizer for the front ends.
  3227. '-fpreprocessed' is implicit if the input file has one of the
  3228. extensions '.i', '.ii' or '.mi'. These are the extensions that GCC
  3229. uses for preprocessed files created by '-save-temps'.
  3230. '-fdirectives-only'
  3231. When preprocessing, handle directives, but do not expand macros.
  3232. The option's behavior depends on the '-E' and '-fpreprocessed'
  3233. options.
  3234. With '-E', preprocessing is limited to the handling of directives
  3235. such as '#define', '#ifdef', and '#error'. Other preprocessor
  3236. operations, such as macro expansion and trigraph conversion are not
  3237. performed. In addition, the '-dD' option is implicitly enabled.
  3238. With '-fpreprocessed', predefinition of command line and most
  3239. builtin macros is disabled. Macros such as '__LINE__', which are
  3240. contextually dependent, are handled normally. This enables
  3241. compilation of files previously preprocessed with '-E
  3242. -fdirectives-only'.
  3243. With both '-E' and '-fpreprocessed', the rules for '-fpreprocessed'
  3244. take precedence. This enables full preprocessing of files
  3245. previously preprocessed with '-E -fdirectives-only'.
  3246. '-fdollars-in-identifiers'
  3247. Accept '$' in identifiers. *Note Identifier characters::.
  3248. '-fextended-identifiers'
  3249. Accept universal character names in identifiers. This option is
  3250. enabled by default for C99 (and later C standard versions) and C++.
  3251. '-fno-canonical-system-headers'
  3252. When preprocessing, do not shorten system header paths with
  3253. canonicalization.
  3254. '-ftabstop=WIDTH'
  3255. Set the distance between tab stops. This helps the preprocessor
  3256. report correct column numbers in warnings or errors, even if tabs
  3257. appear on the line. If the value is less than 1 or greater than
  3258. 100, the option is ignored. The default is 8.
  3259. '-ftrack-macro-expansion[=LEVEL]'
  3260. Track locations of tokens across macro expansions. This allows the
  3261. compiler to emit diagnostic about the current macro expansion stack
  3262. when a compilation error occurs in a macro expansion. Using this
  3263. option makes the preprocessor and the compiler consume more memory.
  3264. The LEVEL parameter can be used to choose the level of precision of
  3265. token location tracking thus decreasing the memory consumption if
  3266. necessary. Value '0' of LEVEL de-activates this option. Value '1'
  3267. tracks tokens locations in a degraded mode for the sake of minimal
  3268. memory overhead. In this mode all tokens resulting from the
  3269. expansion of an argument of a function-like macro have the same
  3270. location. Value '2' tracks tokens locations completely. This
  3271. value is the most memory hungry. When this option is given no
  3272. argument, the default parameter value is '2'.
  3273. Note that '-ftrack-macro-expansion=2' is activated by default.
  3274. '-fmacro-prefix-map=OLD=NEW'
  3275. When preprocessing files residing in directory 'OLD', expand the
  3276. '__FILE__' and '__BASE_FILE__' macros as if the files resided in
  3277. directory 'NEW' instead. This can be used to change an absolute
  3278. path to a relative path by using '.' for NEW which can result in
  3279. more reproducible builds that are location independent. This
  3280. option also affects '__builtin_FILE()' during compilation. See
  3281. also '-ffile-prefix-map'.
  3282. '-fexec-charset=CHARSET'
  3283. Set the execution character set, used for string and character
  3284. constants. The default is UTF-8. CHARSET can be any encoding
  3285. supported by the system's 'iconv' library routine.
  3286. '-fwide-exec-charset=CHARSET'
  3287. Set the wide execution character set, used for wide string and
  3288. character constants. The default is UTF-32 or UTF-16, whichever
  3289. corresponds to the width of 'wchar_t'. As with '-fexec-charset',
  3290. CHARSET can be any encoding supported by the system's 'iconv'
  3291. library routine; however, you will have problems with encodings
  3292. that do not fit exactly in 'wchar_t'.
  3293. '-finput-charset=CHARSET'
  3294. Set the input character set, used for translation from the
  3295. character set of the input file to the source character set used by
  3296. GCC. If the locale does not specify, or GCC cannot get this
  3297. information from the locale, the default is UTF-8. This can be
  3298. overridden by either the locale or this command-line option.
  3299. Currently the command-line option takes precedence if there's a
  3300. conflict. CHARSET can be any encoding supported by the system's
  3301. 'iconv' library routine.
  3302. '-fworking-directory'
  3303. Enable generation of linemarkers in the preprocessor output that
  3304. let the compiler know the current working directory at the time of
  3305. preprocessing. When this option is enabled, the preprocessor
  3306. emits, after the initial linemarker, a second linemarker with the
  3307. current working directory followed by two slashes. GCC uses this
  3308. directory, when it's present in the preprocessed input, as the
  3309. directory emitted as the current working directory in some
  3310. debugging information formats. This option is implicitly enabled
  3311. if debugging information is enabled, but this can be inhibited with
  3312. the negated form '-fno-working-directory'. If the '-P' flag is
  3313. present in the command line, this option has no effect, since no
  3314. '#line' directives are emitted whatsoever.
  3315. '-A PREDICATE=ANSWER'
  3316. Make an assertion with the predicate PREDICATE and answer ANSWER.
  3317. This form is preferred to the older form '-A PREDICATE(ANSWER)',
  3318. which is still supported, because it does not use shell special
  3319. characters. *Note Obsolete Features::.
  3320. '-A -PREDICATE=ANSWER'
  3321. Cancel an assertion with the predicate PREDICATE and answer ANSWER.
  3322. '-C'
  3323. Do not discard comments. All comments are passed through to the
  3324. output file, except for comments in processed directives, which are
  3325. deleted along with the directive.
  3326. You should be prepared for side effects when using '-C'; it causes
  3327. the preprocessor to treat comments as tokens in their own right.
  3328. For example, comments appearing at the start of what would be a
  3329. directive line have the effect of turning that line into an
  3330. ordinary source line, since the first token on the line is no
  3331. longer a '#'.
  3332. '-CC'
  3333. Do not discard comments, including during macro expansion. This is
  3334. like '-C', except that comments contained within macros are also
  3335. passed through to the output file where the macro is expanded.
  3336. In addition to the side effects of the '-C' option, the '-CC'
  3337. option causes all C++-style comments inside a macro to be converted
  3338. to C-style comments. This is to prevent later use of that macro
  3339. from inadvertently commenting out the remainder of the source line.
  3340. The '-CC' option is generally used to support lint comments.
  3341. '-P'
  3342. Inhibit generation of linemarkers in the output from the
  3343. preprocessor. This might be useful when running the preprocessor
  3344. on something that is not C code, and will be sent to a program
  3345. which might be confused by the linemarkers. *Note Preprocessor
  3346. Output::.
  3347. '-traditional'
  3348. '-traditional-cpp'
  3349. Try to imitate the behavior of pre-standard C preprocessors, as
  3350. opposed to ISO C preprocessors. *Note Traditional Mode::.
  3351. Note that GCC does not otherwise attempt to emulate a pre-standard
  3352. C compiler, and these options are only supported with the '-E'
  3353. switch, or when invoking CPP explicitly.
  3354. '-trigraphs'
  3355. Support ISO C trigraphs. These are three-character sequences, all
  3356. starting with '??', that are defined by ISO C to stand for single
  3357. characters. For example, '??/' stands for '\', so ''??/n'' is a
  3358. character constant for a newline. *Note Initial processing::.
  3359. By default, GCC ignores trigraphs, but in standard-conforming modes
  3360. it converts them. See the '-std' and '-ansi' options.
  3361. '-remap'
  3362. Enable special code to work around file systems which only permit
  3363. very short file names, such as MS-DOS.
  3364. '-H'
  3365. Print the name of each header file used, in addition to other
  3366. normal activities. Each name is indented to show how deep in the
  3367. '#include' stack it is. Precompiled header files are also printed,
  3368. even if they are found to be invalid; an invalid precompiled header
  3369. file is printed with '...x' and a valid one with '...!' .
  3370. '-dLETTERS'
  3371. Says to make debugging dumps during compilation as specified by
  3372. LETTERS. The flags documented here are those relevant to the
  3373. preprocessor. Other LETTERS are interpreted by the compiler
  3374. proper, or reserved for future versions of GCC, and so are silently
  3375. ignored. If you specify LETTERS whose behavior conflicts, the
  3376. result is undefined.
  3377. '-dM'
  3378. Instead of the normal output, generate a list of '#define'
  3379. directives for all the macros defined during the execution of
  3380. the preprocessor, including predefined macros. This gives you
  3381. a way of finding out what is predefined in your version of the
  3382. preprocessor. Assuming you have no file 'foo.h', the command
  3383. touch foo.h; cpp -dM foo.h
  3384. shows all the predefined macros.
  3385. '-dD'
  3386. Like '-dM' except in two respects: it does _not_ include the
  3387. predefined macros, and it outputs _both_ the '#define'
  3388. directives and the result of preprocessing. Both kinds of
  3389. output go to the standard output file.
  3390. '-dN'
  3391. Like '-dD', but emit only the macro names, not their
  3392. expansions.
  3393. '-dI'
  3394. Output '#include' directives in addition to the result of
  3395. preprocessing.
  3396. '-dU'
  3397. Like '-dD' except that only macros that are expanded, or whose
  3398. definedness is tested in preprocessor directives, are output;
  3399. the output is delayed until the use or test of the macro; and
  3400. '#undef' directives are also output for macros tested but
  3401. undefined at the time.
  3402. '-fdebug-cpp'
  3403. This option is only useful for debugging GCC. When used from CPP or
  3404. with '-E', it dumps debugging information about location maps.
  3405. Every token in the output is preceded by the dump of the map its
  3406. location belongs to.
  3407. When used from GCC without '-E', this option has no effect.
  3408. '-I DIR'
  3409. '-iquote DIR'
  3410. '-isystem DIR'
  3411. '-idirafter DIR'
  3412. Add the directory DIR to the list of directories to be searched for
  3413. header files during preprocessing. *Note Search Path::. If DIR
  3414. begins with '=' or '$SYSROOT', then the '=' or '$SYSROOT' is
  3415. replaced by the sysroot prefix; see '--sysroot' and '-isysroot'.
  3416. Directories specified with '-iquote' apply only to the quote form
  3417. of the directive, '#include "FILE"'. Directories specified with
  3418. '-I', '-isystem', or '-idirafter' apply to lookup for both the
  3419. '#include "FILE"' and '#include <FILE>' directives.
  3420. You can specify any number or combination of these options on the
  3421. command line to search for header files in several directories.
  3422. The lookup order is as follows:
  3423. 1. For the quote form of the include directive, the directory of
  3424. the current file is searched first.
  3425. 2. For the quote form of the include directive, the directories
  3426. specified by '-iquote' options are searched in left-to-right
  3427. order, as they appear on the command line.
  3428. 3. Directories specified with '-I' options are scanned in
  3429. left-to-right order.
  3430. 4. Directories specified with '-isystem' options are scanned in
  3431. left-to-right order.
  3432. 5. Standard system directories are scanned.
  3433. 6. Directories specified with '-idirafter' options are scanned in
  3434. left-to-right order.
  3435. You can use '-I' to override a system header file, substituting
  3436. your own version, since these directories are searched before the
  3437. standard system header file directories. However, you should not
  3438. use this option to add directories that contain vendor-supplied
  3439. system header files; use '-isystem' for that.
  3440. The '-isystem' and '-idirafter' options also mark the directory as
  3441. a system directory, so that it gets the same special treatment that
  3442. is applied to the standard system directories. *Note System
  3443. Headers::.
  3444. If a standard system include directory, or a directory specified
  3445. with '-isystem', is also specified with '-I', the '-I' option is
  3446. ignored. The directory is still searched but as a system directory
  3447. at its normal position in the system include chain. This is to
  3448. ensure that GCC's procedure to fix buggy system headers and the
  3449. ordering for the '#include_next' directive are not inadvertently
  3450. changed. If you really need to change the search order for system
  3451. directories, use the '-nostdinc' and/or '-isystem' options. *Note
  3452. System Headers::.
  3453. '-I-'
  3454. Split the include path. This option has been deprecated. Please
  3455. use '-iquote' instead for '-I' directories before the '-I-' and
  3456. remove the '-I-' option.
  3457. Any directories specified with '-I' options before '-I-' are
  3458. searched only for headers requested with '#include "FILE"'; they
  3459. are not searched for '#include <FILE>'. If additional directories
  3460. are specified with '-I' options after the '-I-', those directories
  3461. are searched for all '#include' directives.
  3462. In addition, '-I-' inhibits the use of the directory of the current
  3463. file directory as the first search directory for '#include "FILE"'.
  3464. There is no way to override this effect of '-I-'. *Note Search
  3465. Path::.
  3466. '-iprefix PREFIX'
  3467. Specify PREFIX as the prefix for subsequent '-iwithprefix' options.
  3468. If the prefix represents a directory, you should include the final
  3469. '/'.
  3470. '-iwithprefix DIR'
  3471. '-iwithprefixbefore DIR'
  3472. Append DIR to the prefix specified previously with '-iprefix', and
  3473. add the resulting directory to the include search path.
  3474. '-iwithprefixbefore' puts it in the same place '-I' would;
  3475. '-iwithprefix' puts it where '-idirafter' would.
  3476. '-isysroot DIR'
  3477. This option is like the '--sysroot' option, but applies only to
  3478. header files (except for Darwin targets, where it applies to both
  3479. header files and libraries). See the '--sysroot' option for more
  3480. information.
  3481. '-imultilib DIR'
  3482. Use DIR as a subdirectory of the directory containing
  3483. target-specific C++ headers.
  3484. '-nostdinc'
  3485. Do not search the standard system directories for header files.
  3486. Only the directories explicitly specified with '-I', '-iquote',
  3487. '-isystem', and/or '-idirafter' options (and the directory of the
  3488. current file, if appropriate) are searched.
  3489. '-nostdinc++'
  3490. Do not search for header files in the C++-specific standard
  3491. directories, but do still search the other standard directories.
  3492. (This option is used when building the C++ library.)
  3493. '-Wcomment'
  3494. '-Wcomments'
  3495. Warn whenever a comment-start sequence '/*' appears in a '/*'
  3496. comment, or whenever a backslash-newline appears in a '//' comment.
  3497. This warning is enabled by '-Wall'.
  3498. '-Wtrigraphs'
  3499. Warn if any trigraphs are encountered that might change the meaning
  3500. of the program. Trigraphs within comments are not warned about,
  3501. except those that would form escaped newlines.
  3502. This option is implied by '-Wall'. If '-Wall' is not given, this
  3503. option is still enabled unless trigraphs are enabled. To get
  3504. trigraph conversion without warnings, but get the other '-Wall'
  3505. warnings, use '-trigraphs -Wall -Wno-trigraphs'.
  3506. '-Wundef'
  3507. Warn if an undefined identifier is evaluated in an '#if' directive.
  3508. Such identifiers are replaced with zero.
  3509. '-Wexpansion-to-defined'
  3510. Warn whenever 'defined' is encountered in the expansion of a macro
  3511. (including the case where the macro is expanded by an '#if'
  3512. directive). Such usage is not portable. This warning is also
  3513. enabled by '-Wpedantic' and '-Wextra'.
  3514. '-Wunused-macros'
  3515. Warn about macros defined in the main file that are unused. A
  3516. macro is "used" if it is expanded or tested for existence at least
  3517. once. The preprocessor also warns if the macro has not been used
  3518. at the time it is redefined or undefined.
  3519. Built-in macros, macros defined on the command line, and macros
  3520. defined in include files are not warned about.
  3521. _Note:_ If a macro is actually used, but only used in skipped
  3522. conditional blocks, then the preprocessor reports it as unused. To
  3523. avoid the warning in such a case, you might improve the scope of
  3524. the macro's definition by, for example, moving it into the first
  3525. skipped block. Alternatively, you could provide a dummy use with
  3526. something like:
  3527. #if defined the_macro_causing_the_warning
  3528. #endif
  3529. '-Wno-endif-labels'
  3530. Do not warn whenever an '#else' or an '#endif' are followed by
  3531. text. This sometimes happens in older programs with code of the
  3532. form
  3533. #if FOO
  3534. ...
  3535. #else FOO
  3536. ...
  3537. #endif FOO
  3538. The second and third 'FOO' should be in comments. This warning is
  3539. on by default.
  3540. 
  3541. File: cpp.info, Node: Environment Variables, Next: GNU Free Documentation License, Prev: Invocation, Up: Top
  3542. 13 Environment Variables
  3543. ************************
  3544. This section describes the environment variables that affect how CPP
  3545. operates. You can use them to specify directories or prefixes to use
  3546. when searching for include files, or to control dependency output.
  3547. Note that you can also specify places to search using options such as
  3548. '-I', and control dependency output with options like '-M' (*note
  3549. Invocation::). These take precedence over environment variables, which
  3550. in turn take precedence over the configuration of GCC.
  3551. 'CPATH'
  3552. 'C_INCLUDE_PATH'
  3553. 'CPLUS_INCLUDE_PATH'
  3554. 'OBJC_INCLUDE_PATH'
  3555. Each variable's value is a list of directories separated by a
  3556. special character, much like 'PATH', in which to look for header
  3557. files. The special character, 'PATH_SEPARATOR', is
  3558. target-dependent and determined at GCC build time. For Microsoft
  3559. Windows-based targets it is a semicolon, and for almost all other
  3560. targets it is a colon.
  3561. 'CPATH' specifies a list of directories to be searched as if
  3562. specified with '-I', but after any paths given with '-I' options on
  3563. the command line. This environment variable is used regardless of
  3564. which language is being preprocessed.
  3565. The remaining environment variables apply only when preprocessing
  3566. the particular language indicated. Each specifies a list of
  3567. directories to be searched as if specified with '-isystem', but
  3568. after any paths given with '-isystem' options on the command line.
  3569. In all these variables, an empty element instructs the compiler to
  3570. search its current working directory. Empty elements can appear at
  3571. the beginning or end of a path. For instance, if the value of
  3572. 'CPATH' is ':/special/include', that has the same effect as
  3573. '-I. -I/special/include'.
  3574. See also *note Search Path::.
  3575. 'DEPENDENCIES_OUTPUT'
  3576. If this variable is set, its value specifies how to output
  3577. dependencies for Make based on the non-system header files
  3578. processed by the compiler. System header files are ignored in the
  3579. dependency output.
  3580. The value of 'DEPENDENCIES_OUTPUT' can be just a file name, in
  3581. which case the Make rules are written to that file, guessing the
  3582. target name from the source file name. Or the value can have the
  3583. form 'FILE TARGET', in which case the rules are written to file
  3584. FILE using TARGET as the target name.
  3585. In other words, this environment variable is equivalent to
  3586. combining the options '-MM' and '-MF' (*note Invocation::), with an
  3587. optional '-MT' switch too.
  3588. 'SUNPRO_DEPENDENCIES'
  3589. This variable is the same as 'DEPENDENCIES_OUTPUT' (see above),
  3590. except that system header files are not ignored, so it implies '-M'
  3591. rather than '-MM'. However, the dependence on the main input file
  3592. is omitted. *Note Invocation::.
  3593. 'SOURCE_DATE_EPOCH'
  3594. If this variable is set, its value specifies a UNIX timestamp to be
  3595. used in replacement of the current date and time in the '__DATE__'
  3596. and '__TIME__' macros, so that the embedded timestamps become
  3597. reproducible.
  3598. The value of 'SOURCE_DATE_EPOCH' must be a UNIX timestamp, defined
  3599. as the number of seconds (excluding leap seconds) since 01 Jan 1970
  3600. 00:00:00 represented in ASCII; identical to the output of ''date
  3601. +%s'' on GNU/Linux and other systems that support the '%s'
  3602. extension in the 'date' command.
  3603. The value should be a known timestamp such as the last modification
  3604. time of the source or package and it should be set by the build
  3605. process.
  3606. 
  3607. File: cpp.info, Node: GNU Free Documentation License, Next: Index of Directives, Prev: Environment Variables, Up: Top
  3608. GNU Free Documentation License
  3609. ******************************
  3610. Version 1.3, 3 November 2008
  3611. Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
  3612. <http://fsf.org/>
  3613. Everyone is permitted to copy and distribute verbatim copies
  3614. of this license document, but changing it is not allowed.
  3615. 0. PREAMBLE
  3616. The purpose of this License is to make a manual, textbook, or other
  3617. functional and useful document "free" in the sense of freedom: to
  3618. assure everyone the effective freedom to copy and redistribute it,
  3619. with or without modifying it, either commercially or
  3620. noncommercially. Secondarily, this License preserves for the
  3621. author and publisher a way to get credit for their work, while not
  3622. being considered responsible for modifications made by others.
  3623. This License is a kind of "copyleft", which means that derivative
  3624. works of the document must themselves be free in the same sense.
  3625. It complements the GNU General Public License, which is a copyleft
  3626. license designed for free software.
  3627. We have designed this License in order to use it for manuals for
  3628. free software, because free software needs free documentation: a
  3629. free program should come with manuals providing the same freedoms
  3630. that the software does. But this License is not limited to
  3631. software manuals; it can be used for any textual work, regardless
  3632. of subject matter or whether it is published as a printed book. We
  3633. recommend this License principally for works whose purpose is
  3634. instruction or reference.
  3635. 1. APPLICABILITY AND DEFINITIONS
  3636. This License applies to any manual or other work, in any medium,
  3637. that contains a notice placed by the copyright holder saying it can
  3638. be distributed under the terms of this License. Such a notice
  3639. grants a world-wide, royalty-free license, unlimited in duration,
  3640. to use that work under the conditions stated herein. The
  3641. "Document", below, refers to any such manual or work. Any member
  3642. of the public is a licensee, and is addressed as "you". You accept
  3643. the license if you copy, modify or distribute the work in a way
  3644. requiring permission under copyright law.
  3645. A "Modified Version" of the Document means any work containing the
  3646. Document or a portion of it, either copied verbatim, or with
  3647. modifications and/or translated into another language.
  3648. A "Secondary Section" is a named appendix or a front-matter section
  3649. of the Document that deals exclusively with the relationship of the
  3650. publishers or authors of the Document to the Document's overall
  3651. subject (or to related matters) and contains nothing that could
  3652. fall directly within that overall subject. (Thus, if the Document
  3653. is in part a textbook of mathematics, a Secondary Section may not
  3654. explain any mathematics.) The relationship could be a matter of
  3655. historical connection with the subject or with related matters, or
  3656. of legal, commercial, philosophical, ethical or political position
  3657. regarding them.
  3658. The "Invariant Sections" are certain Secondary Sections whose
  3659. titles are designated, as being those of Invariant Sections, in the
  3660. notice that says that the Document is released under this License.
  3661. If a section does not fit the above definition of Secondary then it
  3662. is not allowed to be designated as Invariant. The Document may
  3663. contain zero Invariant Sections. If the Document does not identify
  3664. any Invariant Sections then there are none.
  3665. The "Cover Texts" are certain short passages of text that are
  3666. listed, as Front-Cover Texts or Back-Cover Texts, in the notice
  3667. that says that the Document is released under this License. A
  3668. Front-Cover Text may be at most 5 words, and a Back-Cover Text may
  3669. be at most 25 words.
  3670. A "Transparent" copy of the Document means a machine-readable copy,
  3671. represented in a format whose specification is available to the
  3672. general public, that is suitable for revising the document
  3673. straightforwardly with generic text editors or (for images composed
  3674. of pixels) generic paint programs or (for drawings) some widely
  3675. available drawing editor, and that is suitable for input to text
  3676. formatters or for automatic translation to a variety of formats
  3677. suitable for input to text formatters. A copy made in an otherwise
  3678. Transparent file format whose markup, or absence of markup, has
  3679. been arranged to thwart or discourage subsequent modification by
  3680. readers is not Transparent. An image format is not Transparent if
  3681. used for any substantial amount of text. A copy that is not
  3682. "Transparent" is called "Opaque".
  3683. Examples of suitable formats for Transparent copies include plain
  3684. ASCII without markup, Texinfo input format, LaTeX input format,
  3685. SGML or XML using a publicly available DTD, and standard-conforming
  3686. simple HTML, PostScript or PDF designed for human modification.
  3687. Examples of transparent image formats include PNG, XCF and JPG.
  3688. Opaque formats include proprietary formats that can be read and
  3689. edited only by proprietary word processors, SGML or XML for which
  3690. the DTD and/or processing tools are not generally available, and
  3691. the machine-generated HTML, PostScript or PDF produced by some word
  3692. processors for output purposes only.
  3693. The "Title Page" means, for a printed book, the title page itself,
  3694. plus such following pages as are needed to hold, legibly, the
  3695. material this License requires to appear in the title page. For
  3696. works in formats which do not have any title page as such, "Title
  3697. Page" means the text near the most prominent appearance of the
  3698. work's title, preceding the beginning of the body of the text.
  3699. The "publisher" means any person or entity that distributes copies
  3700. of the Document to the public.
  3701. A section "Entitled XYZ" means a named subunit of the Document
  3702. whose title either is precisely XYZ or contains XYZ in parentheses
  3703. following text that translates XYZ in another language. (Here XYZ
  3704. stands for a specific section name mentioned below, such as
  3705. "Acknowledgements", "Dedications", "Endorsements", or "History".)
  3706. To "Preserve the Title" of such a section when you modify the
  3707. Document means that it remains a section "Entitled XYZ" according
  3708. to this definition.
  3709. The Document may include Warranty Disclaimers next to the notice
  3710. which states that this License applies to the Document. These
  3711. Warranty Disclaimers are considered to be included by reference in
  3712. this License, but only as regards disclaiming warranties: any other
  3713. implication that these Warranty Disclaimers may have is void and
  3714. has no effect on the meaning of this License.
  3715. 2. VERBATIM COPYING
  3716. You may copy and distribute the Document in any medium, either
  3717. commercially or noncommercially, provided that this License, the
  3718. copyright notices, and the license notice saying this License
  3719. applies to the Document are reproduced in all copies, and that you
  3720. add no other conditions whatsoever to those of this License. You
  3721. may not use technical measures to obstruct or control the reading
  3722. or further copying of the copies you make or distribute. However,
  3723. you may accept compensation in exchange for copies. If you
  3724. distribute a large enough number of copies you must also follow the
  3725. conditions in section 3.
  3726. You may also lend copies, under the same conditions stated above,
  3727. and you may publicly display copies.
  3728. 3. COPYING IN QUANTITY
  3729. If you publish printed copies (or copies in media that commonly
  3730. have printed covers) of the Document, numbering more than 100, and
  3731. the Document's license notice requires Cover Texts, you must
  3732. enclose the copies in covers that carry, clearly and legibly, all
  3733. these Cover Texts: Front-Cover Texts on the front cover, and
  3734. Back-Cover Texts on the back cover. Both covers must also clearly
  3735. and legibly identify you as the publisher of these copies. The
  3736. front cover must present the full title with all words of the title
  3737. equally prominent and visible. You may add other material on the
  3738. covers in addition. Copying with changes limited to the covers, as
  3739. long as they preserve the title of the Document and satisfy these
  3740. conditions, can be treated as verbatim copying in other respects.
  3741. If the required texts for either cover are too voluminous to fit
  3742. legibly, you should put the first ones listed (as many as fit
  3743. reasonably) on the actual cover, and continue the rest onto
  3744. adjacent pages.
  3745. If you publish or distribute Opaque copies of the Document
  3746. numbering more than 100, you must either include a machine-readable
  3747. Transparent copy along with each Opaque copy, or state in or with
  3748. each Opaque copy a computer-network location from which the general
  3749. network-using public has access to download using public-standard
  3750. network protocols a complete Transparent copy of the Document, free
  3751. of added material. If you use the latter option, you must take
  3752. reasonably prudent steps, when you begin distribution of Opaque
  3753. copies in quantity, to ensure that this Transparent copy will
  3754. remain thus accessible at the stated location until at least one
  3755. year after the last time you distribute an Opaque copy (directly or
  3756. through your agents or retailers) of that edition to the public.
  3757. It is requested, but not required, that you contact the authors of
  3758. the Document well before redistributing any large number of copies,
  3759. to give them a chance to provide you with an updated version of the
  3760. Document.
  3761. 4. MODIFICATIONS
  3762. You may copy and distribute a Modified Version of the Document
  3763. under the conditions of sections 2 and 3 above, provided that you
  3764. release the Modified Version under precisely this License, with the
  3765. Modified Version filling the role of the Document, thus licensing
  3766. distribution and modification of the Modified Version to whoever
  3767. possesses a copy of it. In addition, you must do these things in
  3768. the Modified Version:
  3769. A. Use in the Title Page (and on the covers, if any) a title
  3770. distinct from that of the Document, and from those of previous
  3771. versions (which should, if there were any, be listed in the
  3772. History section of the Document). You may use the same title
  3773. as a previous version if the original publisher of that
  3774. version gives permission.
  3775. B. List on the Title Page, as authors, one or more persons or
  3776. entities responsible for authorship of the modifications in
  3777. the Modified Version, together with at least five of the
  3778. principal authors of the Document (all of its principal
  3779. authors, if it has fewer than five), unless they release you
  3780. from this requirement.
  3781. C. State on the Title page the name of the publisher of the
  3782. Modified Version, as the publisher.
  3783. D. Preserve all the copyright notices of the Document.
  3784. E. Add an appropriate copyright notice for your modifications
  3785. adjacent to the other copyright notices.
  3786. F. Include, immediately after the copyright notices, a license
  3787. notice giving the public permission to use the Modified
  3788. Version under the terms of this License, in the form shown in
  3789. the Addendum below.
  3790. G. Preserve in that license notice the full lists of Invariant
  3791. Sections and required Cover Texts given in the Document's
  3792. license notice.
  3793. H. Include an unaltered copy of this License.
  3794. I. Preserve the section Entitled "History", Preserve its Title,
  3795. and add to it an item stating at least the title, year, new
  3796. authors, and publisher of the Modified Version as given on the
  3797. Title Page. If there is no section Entitled "History" in the
  3798. Document, create one stating the title, year, authors, and
  3799. publisher of the Document as given on its Title Page, then add
  3800. an item describing the Modified Version as stated in the
  3801. previous sentence.
  3802. J. Preserve the network location, if any, given in the Document
  3803. for public access to a Transparent copy of the Document, and
  3804. likewise the network locations given in the Document for
  3805. previous versions it was based on. These may be placed in the
  3806. "History" section. You may omit a network location for a work
  3807. that was published at least four years before the Document
  3808. itself, or if the original publisher of the version it refers
  3809. to gives permission.
  3810. K. For any section Entitled "Acknowledgements" or "Dedications",
  3811. Preserve the Title of the section, and preserve in the section
  3812. all the substance and tone of each of the contributor
  3813. acknowledgements and/or dedications given therein.
  3814. L. Preserve all the Invariant Sections of the Document, unaltered
  3815. in their text and in their titles. Section numbers or the
  3816. equivalent are not considered part of the section titles.
  3817. M. Delete any section Entitled "Endorsements". Such a section
  3818. may not be included in the Modified Version.
  3819. N. Do not retitle any existing section to be Entitled
  3820. "Endorsements" or to conflict in title with any Invariant
  3821. Section.
  3822. O. Preserve any Warranty Disclaimers.
  3823. If the Modified Version includes new front-matter sections or
  3824. appendices that qualify as Secondary Sections and contain no
  3825. material copied from the Document, you may at your option designate
  3826. some or all of these sections as invariant. To do this, add their
  3827. titles to the list of Invariant Sections in the Modified Version's
  3828. license notice. These titles must be distinct from any other
  3829. section titles.
  3830. You may add a section Entitled "Endorsements", provided it contains
  3831. nothing but endorsements of your Modified Version by various
  3832. parties--for example, statements of peer review or that the text
  3833. has been approved by an organization as the authoritative
  3834. definition of a standard.
  3835. You may add a passage of up to five words as a Front-Cover Text,
  3836. and a passage of up to 25 words as a Back-Cover Text, to the end of
  3837. the list of Cover Texts in the Modified Version. Only one passage
  3838. of Front-Cover Text and one of Back-Cover Text may be added by (or
  3839. through arrangements made by) any one entity. If the Document
  3840. already includes a cover text for the same cover, previously added
  3841. by you or by arrangement made by the same entity you are acting on
  3842. behalf of, you may not add another; but you may replace the old
  3843. one, on explicit permission from the previous publisher that added
  3844. the old one.
  3845. The author(s) and publisher(s) of the Document do not by this
  3846. License give permission to use their names for publicity for or to
  3847. assert or imply endorsement of any Modified Version.
  3848. 5. COMBINING DOCUMENTS
  3849. You may combine the Document with other documents released under
  3850. this License, under the terms defined in section 4 above for
  3851. modified versions, provided that you include in the combination all
  3852. of the Invariant Sections of all of the original documents,
  3853. unmodified, and list them all as Invariant Sections of your
  3854. combined work in its license notice, and that you preserve all
  3855. their Warranty Disclaimers.
  3856. The combined work need only contain one copy of this License, and
  3857. multiple identical Invariant Sections may be replaced with a single
  3858. copy. If there are multiple Invariant Sections with the same name
  3859. but different contents, make the title of each such section unique
  3860. by adding at the end of it, in parentheses, the name of the
  3861. original author or publisher of that section if known, or else a
  3862. unique number. Make the same adjustment to the section titles in
  3863. the list of Invariant Sections in the license notice of the
  3864. combined work.
  3865. In the combination, you must combine any sections Entitled
  3866. "History" in the various original documents, forming one section
  3867. Entitled "History"; likewise combine any sections Entitled
  3868. "Acknowledgements", and any sections Entitled "Dedications". You
  3869. must delete all sections Entitled "Endorsements."
  3870. 6. COLLECTIONS OF DOCUMENTS
  3871. You may make a collection consisting of the Document and other
  3872. documents released under this License, and replace the individual
  3873. copies of this License in the various documents with a single copy
  3874. that is included in the collection, provided that you follow the
  3875. rules of this License for verbatim copying of each of the documents
  3876. in all other respects.
  3877. You may extract a single document from such a collection, and
  3878. distribute it individually under this License, provided you insert
  3879. a copy of this License into the extracted document, and follow this
  3880. License in all other respects regarding verbatim copying of that
  3881. document.
  3882. 7. AGGREGATION WITH INDEPENDENT WORKS
  3883. A compilation of the Document or its derivatives with other
  3884. separate and independent documents or works, in or on a volume of a
  3885. storage or distribution medium, is called an "aggregate" if the
  3886. copyright resulting from the compilation is not used to limit the
  3887. legal rights of the compilation's users beyond what the individual
  3888. works permit. When the Document is included in an aggregate, this
  3889. License does not apply to the other works in the aggregate which
  3890. are not themselves derivative works of the Document.
  3891. If the Cover Text requirement of section 3 is applicable to these
  3892. copies of the Document, then if the Document is less than one half
  3893. of the entire aggregate, the Document's Cover Texts may be placed
  3894. on covers that bracket the Document within the aggregate, or the
  3895. electronic equivalent of covers if the Document is in electronic
  3896. form. Otherwise they must appear on printed covers that bracket
  3897. the whole aggregate.
  3898. 8. TRANSLATION
  3899. Translation is considered a kind of modification, so you may
  3900. distribute translations of the Document under the terms of section
  3901. 4. Replacing Invariant Sections with translations requires special
  3902. permission from their copyright holders, but you may include
  3903. translations of some or all Invariant Sections in addition to the
  3904. original versions of these Invariant Sections. You may include a
  3905. translation of this License, and all the license notices in the
  3906. Document, and any Warranty Disclaimers, provided that you also
  3907. include the original English version of this License and the
  3908. original versions of those notices and disclaimers. In case of a
  3909. disagreement between the translation and the original version of
  3910. this License or a notice or disclaimer, the original version will
  3911. prevail.
  3912. If a section in the Document is Entitled "Acknowledgements",
  3913. "Dedications", or "History", the requirement (section 4) to
  3914. Preserve its Title (section 1) will typically require changing the
  3915. actual title.
  3916. 9. TERMINATION
  3917. You may not copy, modify, sublicense, or distribute the Document
  3918. except as expressly provided under this License. Any attempt
  3919. otherwise to copy, modify, sublicense, or distribute it is void,
  3920. and will automatically terminate your rights under this License.
  3921. However, if you cease all violation of this License, then your
  3922. license from a particular copyright holder is reinstated (a)
  3923. provisionally, unless and until the copyright holder explicitly and
  3924. finally terminates your license, and (b) permanently, if the
  3925. copyright holder fails to notify you of the violation by some
  3926. reasonable means prior to 60 days after the cessation.
  3927. Moreover, your license from a particular copyright holder is
  3928. reinstated permanently if the copyright holder notifies you of the
  3929. violation by some reasonable means, this is the first time you have
  3930. received notice of violation of this License (for any work) from
  3931. that copyright holder, and you cure the violation prior to 30 days
  3932. after your receipt of the notice.
  3933. Termination of your rights under this section does not terminate
  3934. the licenses of parties who have received copies or rights from you
  3935. under this License. If your rights have been terminated and not
  3936. permanently reinstated, receipt of a copy of some or all of the
  3937. same material does not give you any rights to use it.
  3938. 10. FUTURE REVISIONS OF THIS LICENSE
  3939. The Free Software Foundation may publish new, revised versions of
  3940. the GNU Free Documentation License from time to time. Such new
  3941. versions will be similar in spirit to the present version, but may
  3942. differ in detail to address new problems or concerns. See
  3943. <http://www.gnu.org/copyleft/>.
  3944. Each version of the License is given a distinguishing version
  3945. number. If the Document specifies that a particular numbered
  3946. version of this License "or any later version" applies to it, you
  3947. have the option of following the terms and conditions either of
  3948. that specified version or of any later version that has been
  3949. published (not as a draft) by the Free Software Foundation. If the
  3950. Document does not specify a version number of this License, you may
  3951. choose any version ever published (not as a draft) by the Free
  3952. Software Foundation. If the Document specifies that a proxy can
  3953. decide which future versions of this License can be used, that
  3954. proxy's public statement of acceptance of a version permanently
  3955. authorizes you to choose that version for the Document.
  3956. 11. RELICENSING
  3957. "Massive Multiauthor Collaboration Site" (or "MMC Site") means any
  3958. World Wide Web server that publishes copyrightable works and also
  3959. provides prominent facilities for anybody to edit those works. A
  3960. public wiki that anybody can edit is an example of such a server.
  3961. A "Massive Multiauthor Collaboration" (or "MMC") contained in the
  3962. site means any set of copyrightable works thus published on the MMC
  3963. site.
  3964. "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
  3965. license published by Creative Commons Corporation, a not-for-profit
  3966. corporation with a principal place of business in San Francisco,
  3967. California, as well as future copyleft versions of that license
  3968. published by that same organization.
  3969. "Incorporate" means to publish or republish a Document, in whole or
  3970. in part, as part of another Document.
  3971. An MMC is "eligible for relicensing" if it is licensed under this
  3972. License, and if all works that were first published under this
  3973. License somewhere other than this MMC, and subsequently
  3974. incorporated in whole or in part into the MMC, (1) had no cover
  3975. texts or invariant sections, and (2) were thus incorporated prior
  3976. to November 1, 2008.
  3977. The operator of an MMC Site may republish an MMC contained in the
  3978. site under CC-BY-SA on the same site at any time before August 1,
  3979. 2009, provided the MMC is eligible for relicensing.
  3980. ADDENDUM: How to use this License for your documents
  3981. ====================================================
  3982. To use this License in a document you have written, include a copy of
  3983. the License in the document and put the following copyright and license
  3984. notices just after the title page:
  3985. Copyright (C) YEAR YOUR NAME.
  3986. Permission is granted to copy, distribute and/or modify this document
  3987. under the terms of the GNU Free Documentation License, Version 1.3
  3988. or any later version published by the Free Software Foundation;
  3989. with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
  3990. Texts. A copy of the license is included in the section entitled ``GNU
  3991. Free Documentation License''.
  3992. If you have Invariant Sections, Front-Cover Texts and Back-Cover
  3993. Texts, replace the "with...Texts." line with this:
  3994. with the Invariant Sections being LIST THEIR TITLES, with
  3995. the Front-Cover Texts being LIST, and with the Back-Cover Texts
  3996. being LIST.
  3997. If you have Invariant Sections without Cover Texts, or some other
  3998. combination of the three, merge those two alternatives to suit the
  3999. situation.
  4000. If your document contains nontrivial examples of program code, we
  4001. recommend releasing these examples in parallel under your choice of free
  4002. software license, such as the GNU General Public License, to permit
  4003. their use in free software.
  4004. 
  4005. File: cpp.info, Node: Index of Directives, Next: Option Index, Prev: GNU Free Documentation License, Up: Top
  4006. Index of Directives
  4007. *******************
  4008. �[index�]
  4009. * Menu:
  4010. * #assert: Obsolete Features. (line 48)
  4011. * #define: Object-like Macros. (line 11)
  4012. * #elif: Elif. (line 6)
  4013. * #else: Else. (line 6)
  4014. * #endif: Ifdef. (line 6)
  4015. * #error: Diagnostics. (line 6)
  4016. * #ident: Other Directives. (line 6)
  4017. * #if: Conditional Syntax. (line 6)
  4018. * #ifdef: Ifdef. (line 6)
  4019. * #ifndef: Ifdef. (line 40)
  4020. * #import: Alternatives to Wrapper #ifndef.
  4021. (line 11)
  4022. * #include: Include Syntax. (line 6)
  4023. * #include_next: Wrapper Headers. (line 6)
  4024. * #line: Line Control. (line 20)
  4025. * #pragma GCC dependency: Pragmas. (line 43)
  4026. * #pragma GCC error: Pragmas. (line 88)
  4027. * #pragma GCC poison: Pragmas. (line 55)
  4028. * #pragma GCC system_header: System Headers. (line 25)
  4029. * #pragma GCC system_header <1>: Pragmas. (line 82)
  4030. * #pragma GCC warning: Pragmas. (line 87)
  4031. * #sccs: Other Directives. (line 6)
  4032. * #unassert: Obsolete Features. (line 59)
  4033. * #undef: Undefining and Redefining Macros.
  4034. (line 6)
  4035. * #warning: Diagnostics. (line 27)
  4036. 
  4037. File: cpp.info, Node: Option Index, Next: Concept Index, Prev: Index of Directives, Up: Top
  4038. Option Index
  4039. ************
  4040. CPP's command-line options and environment variables are indexed here
  4041. without any initial '-' or '--'.
  4042. �[index�]
  4043. * Menu:
  4044. * A: Invocation. (line 329)
  4045. * C: Invocation. (line 338)
  4046. * CC: Invocation. (line 350)
  4047. * CPATH: Environment Variables.
  4048. (line 15)
  4049. * CPLUS_INCLUDE_PATH: Environment Variables.
  4050. (line 17)
  4051. * C_INCLUDE_PATH: Environment Variables.
  4052. (line 16)
  4053. * D: Invocation. (line 44)
  4054. * d: Invocation. (line 399)
  4055. * dD: Invocation. (line 418)
  4056. * DEPENDENCIES_OUTPUT: Environment Variables.
  4057. (line 45)
  4058. * dI: Invocation. (line 428)
  4059. * dM: Invocation. (line 407)
  4060. * dN: Invocation. (line 424)
  4061. * dU: Invocation. (line 432)
  4062. * fdebug-cpp: Invocation. (line 439)
  4063. * fdirectives-only: Invocation. (line 228)
  4064. * fdollars-in-identifiers: Invocation. (line 249)
  4065. * fexec-charset: Invocation. (line 292)
  4066. * fextended-identifiers: Invocation. (line 252)
  4067. * finput-charset: Invocation. (line 305)
  4068. * fmacro-prefix-map: Invocation. (line 283)
  4069. * fno-canonical-system-headers: Invocation. (line 256)
  4070. * fno-working-directory: Invocation. (line 315)
  4071. * fpreprocessed: Invocation. (line 215)
  4072. * ftabstop: Invocation. (line 260)
  4073. * ftrack-macro-expansion: Invocation. (line 266)
  4074. * fwide-exec-charset: Invocation. (line 297)
  4075. * fworking-directory: Invocation. (line 315)
  4076. * H: Invocation. (line 392)
  4077. * I: Invocation. (line 450)
  4078. * I-: Invocation. (line 504)
  4079. * idirafter: Invocation. (line 450)
  4080. * imacros: Invocation. (line 82)
  4081. * imultilib: Invocation. (line 538)
  4082. * include: Invocation. (line 71)
  4083. * iprefix: Invocation. (line 520)
  4084. * iquote: Invocation. (line 450)
  4085. * isysroot: Invocation. (line 532)
  4086. * isystem: Invocation. (line 450)
  4087. * iwithprefix: Invocation. (line 526)
  4088. * iwithprefixbefore: Invocation. (line 526)
  4089. * M: Invocation. (line 103)
  4090. * MD: Invocation. (line 195)
  4091. * MF: Invocation. (line 137)
  4092. * MG: Invocation. (line 148)
  4093. * MM: Invocation. (line 128)
  4094. * MMD: Invocation. (line 211)
  4095. * MP: Invocation. (line 158)
  4096. * MQ: Invocation. (line 185)
  4097. * MT: Invocation. (line 170)
  4098. * nostdinc: Invocation. (line 542)
  4099. * nostdinc++: Invocation. (line 548)
  4100. * OBJC_INCLUDE_PATH: Environment Variables.
  4101. (line 18)
  4102. * P: Invocation. (line 362)
  4103. * pthread: Invocation. (line 96)
  4104. * remap: Invocation. (line 388)
  4105. * SOURCE_DATE_EPOCH: Environment Variables.
  4106. (line 67)
  4107. * SUNPRO_DEPENDENCIES: Environment Variables.
  4108. (line 61)
  4109. * traditional: Invocation. (line 370)
  4110. * traditional-cpp: Invocation. (line 370)
  4111. * trigraphs: Invocation. (line 379)
  4112. * U: Invocation. (line 67)
  4113. * undef: Invocation. (line 91)
  4114. * Wcomment: Invocation. (line 554)
  4115. * Wcomments: Invocation. (line 554)
  4116. * Wendif-labels: Invocation. (line 598)
  4117. * Wexpansion-to-defined: Invocation. (line 573)
  4118. * Wno-endif-labels: Invocation. (line 598)
  4119. * Wno-undef: Invocation. (line 569)
  4120. * Wtrigraphs: Invocation. (line 559)
  4121. * Wundef: Invocation. (line 569)
  4122. * Wunused-macros: Invocation. (line 579)
  4123. 
  4124. File: cpp.info, Node: Concept Index, Prev: Option Index, Up: Top
  4125. Concept Index
  4126. *************
  4127. �[index�]
  4128. * Menu:
  4129. * # operator: Stringizing. (line 6)
  4130. * ## operator: Concatenation. (line 6)
  4131. * _Pragma: Pragmas. (line 13)
  4132. * alternative tokens: Tokenization. (line 101)
  4133. * arguments: Macro Arguments. (line 6)
  4134. * arguments in macro definitions: Macro Arguments. (line 6)
  4135. * assertions: Obsolete Features. (line 13)
  4136. * assertions, canceling: Obsolete Features. (line 59)
  4137. * backslash-newline: Initial processing. (line 61)
  4138. * block comments: Initial processing. (line 77)
  4139. * C language, traditional: Invocation. (line 368)
  4140. * C++ named operators: C++ Named Operators. (line 6)
  4141. * character constants: Tokenization. (line 82)
  4142. * character set, execution: Invocation. (line 292)
  4143. * character set, input: Invocation. (line 305)
  4144. * character set, wide execution: Invocation. (line 297)
  4145. * command line: Invocation. (line 6)
  4146. * commenting out code: Deleted Code. (line 6)
  4147. * comments: Initial processing. (line 77)
  4148. * common predefined macros: Common Predefined Macros.
  4149. (line 6)
  4150. * computed includes: Computed Includes. (line 6)
  4151. * concatenation: Concatenation. (line 6)
  4152. * conditional group: Ifdef. (line 14)
  4153. * conditionals: Conditionals. (line 6)
  4154. * continued lines: Initial processing. (line 61)
  4155. * controlling macro: Once-Only Headers. (line 35)
  4156. * defined: Defined. (line 6)
  4157. * dependencies for make as output: Environment Variables.
  4158. (line 46)
  4159. * dependencies for make as output <1>: Environment Variables.
  4160. (line 62)
  4161. * dependencies, make: Invocation. (line 103)
  4162. * diagnostic: Diagnostics. (line 6)
  4163. * digraphs: Tokenization. (line 101)
  4164. * directive line: The preprocessing language.
  4165. (line 6)
  4166. * directive name: The preprocessing language.
  4167. (line 6)
  4168. * directives: The preprocessing language.
  4169. (line 6)
  4170. * empty macro arguments: Macro Arguments. (line 66)
  4171. * environment variables: Environment Variables.
  4172. (line 6)
  4173. * expansion of arguments: Argument Prescan. (line 6)
  4174. * FDL, GNU Free Documentation License: GNU Free Documentation License.
  4175. (line 6)
  4176. * function-like macros: Function-like Macros.
  4177. (line 6)
  4178. * grouping options: Invocation. (line 38)
  4179. * guard macro: Once-Only Headers. (line 35)
  4180. * header file: Header Files. (line 6)
  4181. * header file names: Tokenization. (line 82)
  4182. * identifiers: Tokenization. (line 33)
  4183. * implementation limits: Implementation limits.
  4184. (line 6)
  4185. * implementation-defined behavior: Implementation-defined behavior.
  4186. (line 6)
  4187. * including just once: Once-Only Headers. (line 6)
  4188. * invocation: Invocation. (line 6)
  4189. * iso646.h: C++ Named Operators. (line 6)
  4190. * line comments: Initial processing. (line 77)
  4191. * line control: Line Control. (line 6)
  4192. * line endings: Initial processing. (line 14)
  4193. * linemarkers: Preprocessor Output. (line 27)
  4194. * macro argument expansion: Argument Prescan. (line 6)
  4195. * macro arguments and directives: Directives Within Macro Arguments.
  4196. (line 6)
  4197. * macros in include: Computed Includes. (line 6)
  4198. * macros with arguments: Macro Arguments. (line 6)
  4199. * macros with variable arguments: Variadic Macros. (line 6)
  4200. * make: Invocation. (line 103)
  4201. * manifest constants: Object-like Macros. (line 6)
  4202. * named operators: C++ Named Operators. (line 6)
  4203. * newlines in macro arguments: Newlines in Arguments.
  4204. (line 6)
  4205. * null directive: Other Directives. (line 15)
  4206. * numbers: Tokenization. (line 59)
  4207. * object-like macro: Object-like Macros. (line 6)
  4208. * options: Invocation. (line 43)
  4209. * options, grouping: Invocation. (line 38)
  4210. * other tokens: Tokenization. (line 115)
  4211. * output format: Preprocessor Output. (line 12)
  4212. * overriding a header file: Wrapper Headers. (line 6)
  4213. * parentheses in macro bodies: Operator Precedence Problems.
  4214. (line 6)
  4215. * pitfalls of macros: Macro Pitfalls. (line 6)
  4216. * predefined macros: Predefined Macros. (line 6)
  4217. * predefined macros, system-specific: System-specific Predefined Macros.
  4218. (line 6)
  4219. * predicates: Obsolete Features. (line 26)
  4220. * preprocessing directives: The preprocessing language.
  4221. (line 6)
  4222. * preprocessing numbers: Tokenization. (line 59)
  4223. * preprocessing tokens: Tokenization. (line 6)
  4224. * prescan of macro arguments: Argument Prescan. (line 6)
  4225. * problems with macros: Macro Pitfalls. (line 6)
  4226. * punctuators: Tokenization. (line 101)
  4227. * redefining macros: Undefining and Redefining Macros.
  4228. (line 6)
  4229. * repeated inclusion: Once-Only Headers. (line 6)
  4230. * reporting errors: Diagnostics. (line 6)
  4231. * reporting warnings: Diagnostics. (line 6)
  4232. * reserved namespace: System-specific Predefined Macros.
  4233. (line 6)
  4234. * self-reference: Self-Referential Macros.
  4235. (line 6)
  4236. * semicolons (after macro calls): Swallowing the Semicolon.
  4237. (line 6)
  4238. * side effects (in macro arguments): Duplication of Side Effects.
  4239. (line 6)
  4240. * standard predefined macros.: Standard Predefined Macros.
  4241. (line 6)
  4242. * string constants: Tokenization. (line 82)
  4243. * string literals: Tokenization. (line 82)
  4244. * stringizing: Stringizing. (line 6)
  4245. * symbolic constants: Object-like Macros. (line 6)
  4246. * system header files: Header Files. (line 13)
  4247. * system header files <1>: System Headers. (line 6)
  4248. * system-specific predefined macros: System-specific Predefined Macros.
  4249. (line 6)
  4250. * testing predicates: Obsolete Features. (line 37)
  4251. * token concatenation: Concatenation. (line 6)
  4252. * token pasting: Concatenation. (line 6)
  4253. * tokens: Tokenization. (line 6)
  4254. * traditional C language: Invocation. (line 368)
  4255. * trigraphs: Initial processing. (line 32)
  4256. * undefining macros: Undefining and Redefining Macros.
  4257. (line 6)
  4258. * unsafe macros: Duplication of Side Effects.
  4259. (line 6)
  4260. * variable number of arguments: Variadic Macros. (line 6)
  4261. * variadic macros: Variadic Macros. (line 6)
  4262. * wrapper #ifndef: Once-Only Headers. (line 6)
  4263. * wrapper headers: Wrapper Headers. (line 6)
  4264. 
  4265. Tag Table:
  4266. Node: Top945
  4267. Node: Overview3506
  4268. Node: Character sets6352
  4269. Ref: Character sets-Footnote-18507
  4270. Node: Initial processing8688
  4271. Ref: trigraphs10247
  4272. Node: Tokenization14447
  4273. Ref: Tokenization-Footnote-121348
  4274. Node: The preprocessing language21459
  4275. Node: Header Files24338
  4276. Node: Include Syntax26254
  4277. Node: Include Operation27891
  4278. Node: Search Path29739
  4279. Node: Once-Only Headers31961
  4280. Node: Alternatives to Wrapper #ifndef33620
  4281. Node: Computed Includes35362
  4282. Node: Wrapper Headers38520
  4283. Node: System Headers40943
  4284. Node: Macros42408
  4285. Node: Object-like Macros43545
  4286. Node: Function-like Macros47135
  4287. Node: Macro Arguments48751
  4288. Node: Stringizing52890
  4289. Node: Concatenation56051
  4290. Node: Variadic Macros59148
  4291. Node: Predefined Macros64100
  4292. Node: Standard Predefined Macros64688
  4293. Node: Common Predefined Macros70902
  4294. Node: System-specific Predefined Macros91845
  4295. Node: C++ Named Operators93868
  4296. Node: Undefining and Redefining Macros94832
  4297. Node: Directives Within Macro Arguments96930
  4298. Node: Macro Pitfalls97871
  4299. Node: Misnesting98404
  4300. Node: Operator Precedence Problems99516
  4301. Node: Swallowing the Semicolon101382
  4302. Node: Duplication of Side Effects103405
  4303. Node: Self-Referential Macros105588
  4304. Node: Argument Prescan107997
  4305. Node: Newlines in Arguments111748
  4306. Node: Conditionals112699
  4307. Node: Conditional Uses114395
  4308. Node: Conditional Syntax115753
  4309. Node: Ifdef116073
  4310. Node: If119230
  4311. Node: Defined121534
  4312. Node: Else122927
  4313. Node: Elif123497
  4314. Node: Deleted Code124786
  4315. Node: Diagnostics126033
  4316. Node: Line Control127582
  4317. Node: Pragmas129860
  4318. Node: Other Directives133993
  4319. Node: Preprocessor Output135043
  4320. Node: Traditional Mode138196
  4321. Node: Traditional lexical analysis139333
  4322. Node: Traditional macros141836
  4323. Node: Traditional miscellany145633
  4324. Node: Traditional warnings146629
  4325. Node: Implementation Details148826
  4326. Node: Implementation-defined behavior149389
  4327. Ref: Identifier characters150139
  4328. Node: Implementation limits153006
  4329. Node: Obsolete Features155679
  4330. Node: Invocation158523
  4331. Ref: dashMF164558
  4332. Ref: fdollars-in-identifiers169137
  4333. Ref: Wtrigraphs183133
  4334. Node: Environment Variables185188
  4335. Node: GNU Free Documentation License188881
  4336. Node: Index of Directives214026
  4337. Node: Option Index216106
  4338. Node: Concept Index222062
  4339. 
  4340. End Tag Table
  4341. 
  4342. Local Variables:
  4343. coding: utf-8
  4344. End: