Merge commit '1f1540205fa6366266184180654434272c425ac2'
[unleashed.git] / usr / src / lib / libpp / common / NOTES
blob85ab42e74b01737b88d51f4b535dab8dd4909e2d
1 C preprocessor features:
3 (1)     The preprocessor is centered around the libpp.a  library.  This
4         library provides a tokenizing implementation of the preprocessing
5         stages of ANSI standard C.  The same library is used to construct
6         a standalone prepreprocessor as well as a C compiler front end
7         that, compiled with the library, eliminates the need for a
8         separate preprocessing pass.  Other C tools requiring C tokenizing
9         can use this library, providing a common interface to C language
10         tokens.
12 (2)     The #pragma interface is exploited to allow the addition of new
13         directives and #pragma's without changing the preprocessor
14         executable.  Most implementation details can be specified by
15         directives in the file "ppdefault.h" that is automatically included
16         (by the standalone cpp library wrapper) as an initialization step.
18 (3)     #assert, #unassert and corresponding #if predicate tests have been
19         added to relieve the conflicts introduced by predefined #define
20         macros (e.g., unix, vax, u3b, ...).  This is the same feature
21         present in the extended Reiser cpp that has been included in the
22         nmake distribution. (NOTE: #assert is a failed experiment)
24 (4)     The implementation is sensitive to the incompatible differences
25         between the Reiser cpp (used by AT&T and BSD compilers) and the new
26         ANSI standard C.  A compatibility dialect implements Reiser
27         features, allowing for a smooth transition to the ANSI standard.
29 (5)     To aid in the transition to ANSI, the preprocessor can do some
30         operations that would normally be done by the lexical analysis
31         stage of a compiler front end:
32         
33         (a)     convert new-style character constants to a form
34                 recognized by all current compilers
36         (b)     concatenate adjacent string literals
38 (6)     The preprocessor can also warn about obsolete constructs used
39         in the compatibility dialect and on non-standard constructs
40         used in the ANSI dialect.  The latter is useful in writing
41         C code that is made to run through other implementations of
42         ANSI standard C.
44 (7)     The preprocessor allows a C language implementor to take
45         advantage of local extensions without invalidating the
46         conformance of the C language implementation.
48 C9X additions:
50 (1)     #pragma STDC ...
51                 special forms always accecpted
53 (2)     _Pragma unary operator for pragmas via macro expansion
54                 _Pragma(string-literal)
55                         #pragma a b c
56                         _Pragma("a b c")
58 (3)     keywords
59                 restrict inline _Bool _Complex _Imaginary
61 (4)     macros
62                 __STDC_VERSION__                199901L
63                 __STDC_IEC_559__                1 or undef
64                 __STDC_IEC_559_COMPLEX__        1 or udef
65                 __STDC_ISO_10646__              yyyymmL
67 (5)     empty arguments allowed in function-like macros
69 (6)     variable arguments via ...
70                 __VA_ARGS__ in replacement list only, expands to var args
71                 only var args is ok (shall only appear in ...)
73 (7)     hex floating constant with binary exponents
74                 xxxxxx[pP]dddd
76 (8)     // style comments
78 (9)     universal characters, even in identifiers!
79                 \uxxxx \Uxxxxxxxx
81 (10)    LL ll ULL ull suffix for long long literals
83 (11)    <stdarg.h> has va_copy()