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