xref: /titanic_44/usr/src/lib/libpp/common/NOTES (revision 0398691684c2596072212e4ca9d7033ad7ccfa54)
1C preprocessor features:
2
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.
11
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.
17
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)
23
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.
28
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
35
36	(b)	concatenate adjacent string literals
37
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.
43
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.
47
48C9X additions:
49
50(1)	#pragma STDC ...
51		special forms always accecpted
52
53(2)	_Pragma unary operator for pragmas via macro expansion
54		_Pragma(string-literal)
55			#pragma a b c
56			_Pragma("a b c")
57
58(3)	keywords
59		restrict inline _Bool _Complex _Imaginary
60
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
66
67(5)	empty arguments allowed in function-like macros
68
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 ...)
72
73(7)	hex floating constant with binary exponents
74		xxxxxx[pP]dddd
75
76(8)	// style comments
77
78(9)	universal characters, even in identifiers!
79		\uxxxx \Uxxxxxxxx
80
81(10)	LL ll ULL ull suffix for long long literals
82
83(11)	<stdarg.h> has va_copy()
84