1

What standards document(s) specify the behavior of the C and/or C++ pre-processors?

Wikipedia suggests http://www.open-std.org/JTC1/SC22/WG14/www/standards is valid for C99. Is it? What about C++ flavours?

mabraham
  • 2,806
  • 3
  • 28
  • 25
  • 1
    The same standard as specifies the rest of the language – Martin G Dec 29 '15 at 16:03
  • 1
    C standard is C11, not C99 (ays the text clearly states). The latter has been withdrawn. For C++ there is also an ISO standard. And there are also no "flavours", but only a single standard (currently C++14). – too honest for this site Dec 29 '15 at 16:04
  • @Martin: Your comment is not clear. Please clarify. – too honest for this site Dec 29 '15 at 16:05
  • I think he means that if you are coding for the c99 standard then the c99 spec is the behavior, and if you are coding to c++11 then that is the spec that defines the behavior... plus I will add ... and if you are using preprocessor macros extensively in c++ you aren't doing it right anyway – Grady Player Dec 29 '15 at 16:09
  • See http://stackoverflow.com/questions/81656/where-do-i-find-the-current-c-or-c-standard-documents for places to buy the standards. – Bill Lynch Dec 29 '15 at 16:12
  • There is a published standard for each standardized version of C++. You can buy them on ISO or ANSI's web site (or read some near-final drafts on the C++ Standard Committee's site). Chapter 16 of the C++14 standard covers the preprocessor and its directives. – wkl Dec 29 '15 at 16:14
  • The official standards cost money. There are draft versions that are freely available. For C, the best C99 draft is [N1256](http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf), which includes the three technical Corrigenda. For the current C11 standard, the [N1570](http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf) draft is available. Similar C++ drafts are available. – Keith Thompson Dec 29 '15 at 16:19
  • @KeithThompson: Funny enough, the linked site already links to these documents. OP just should have read it. – too honest for this site Dec 29 '15 at 16:21
  • @GradyPlayer About your last sentence: I'm willing to bet the authors (and clients) of [Boost.Preprocessor](http://www.boost.org/doc/libs/1_60_0/libs/preprocessor/doc/index.html) and [Chaos](http://sourceforge.net/projects/chaos-pp/) would disagree. – Angew is no longer proud of SO Dec 29 '15 at 16:29

1 Answers1

7

The C language standard (ISO/IEC 9899) specifies how the preprocessor behaves in C.

The C++ standard (ISO/IEC 14882) specifies how the preprocessor behaves in C++.

eerorika
  • 232,697
  • 12
  • 197
  • 326