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