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