NOTES revision da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinC preprocessor features:
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin(1) The preprocessor is centered around the libpp.a library. This
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin library provides a tokenizing implementation of the preprocessing
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin stages of ANSI standard C. The same library is used to construct
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin a standalone prepreprocessor as well as a C compiler front end
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin that, compiled with the library, eliminates the need for a
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin separate preprocessing pass. Other C tools requiring C tokenizing
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin can use this library, providing a common interface to C language
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin tokens.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin(2) The #pragma interface is exploited to allow the addition of new
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin directives and #pragma's without changing the preprocessor
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin executable. Most implementation details can be specified by
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin directives in the file "ppdefault.h" that is automatically included
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin (by the standalone cpp library wrapper) as an initialization step.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin(3) #assert, #unassert and corresponding #if predicate tests have been
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin added to relieve the conflicts introduced by predefined #define
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin macros (e.g., unix, vax, u3b, ...). This is the same feature
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin present in the extended Reiser cpp that has been included in the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin nmake distribution. (NOTE: #assert is a failed experiment)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin(4) The implementation is sensitive to the incompatible differences
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin between the Reiser cpp (used by AT&T and BSD compilers) and the new
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin ANSI standard C. A compatibility dialect implements Reiser
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin features, allowing for a smooth transition to the ANSI standard.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin(5) To aid in the transition to ANSI, the preprocessor can do some
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin operations that would normally be done by the lexical analysis
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin stage of a compiler front end:
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin (a) convert new-style character constants to a form
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin recognized by all current compilers
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin (b) concatenate adjacent string literals
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin(6) The preprocessor can also warn about obsolete constructs used
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin in the compatibility dialect and on non-standard constructs
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin used in the ANSI dialect. The latter is useful in writing
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin C code that is made to run through other implementations of
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin ANSI standard C.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin(7) The preprocessor allows a C language implementor to take
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin advantage of local extensions without invalidating the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin conformance of the C language implementation.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinC9X additions:
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin(1) #pragma STDC ...
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin special forms always accecpted
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin(2) _Pragma unary operator for pragmas via macro expansion
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin _Pragma(string-literal)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin #pragma a b c
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin _Pragma("a b c")
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin(3) keywords
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin restrict inline _Bool _Complex _Imaginary
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin(4) macros
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin __STDC_VERSION__ 199901L
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin __STDC_IEC_559__ 1 or undef
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin __STDC_IEC_559_COMPLEX__ 1 or udef
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin __STDC_ISO_10646__ yyyymmL
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin(5) empty arguments allowed in function-like macros
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin(6) variable arguments via ...
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin __VA_ARGS__ in replacement list only, expands to var args
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin only var args is ok (shall only appear in ...)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin(7) hex floating constant with binary exponents
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin xxxxxx[pP]dddd
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin(8) // style comments
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin(9) universal characters, even in identifiers!
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin \uxxxx \Uxxxxxxxx
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin(10) LL ll ULL ull suffix for long long literals
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin(11) <stdarg.h> has va_copy()