1 ?RCS: $Id: cpp_stuff.U,v 3.0.1.1 1994/10/29 16:08:24 ram Exp $
3 ?RCS: Copyright (c) 1991-1993, Raphael Manfredi
5 ?RCS: You may redistribute only under the terms of the Artistic Licence,
6 ?RCS: as specified in the README file that comes with the distribution.
7 ?RCS: You may reuse parts of this distribution only within the terms of
8 ?RCS: that same Artistic Licence; a copy of which may be found at the root
9 ?RCS: of the source tree for dist 3.0.
11 ?RCS: $Log: cpp_stuff.U,v $
12 ?RCS: Revision 3.0.1.1 1994/10/29 16:08:24 ram
13 ?RCS: patch36: now uses cppstdin instead of plain cpp for consistency (ADO)
14 ?RCS: patch36: remove temporary files when done
16 ?RCS: Revision 3.0 1993/08/18 12:05:36 ram
17 ?RCS: Baseline for dist 3.0 netwide release.
19 ?MAKE:cpp_stuff: cat contains cppstdin cppflags cppminus rm
20 ?MAKE: -pick add $@ %<
22 ?S: This variable contains an identification of the catenation mechanism
23 ?S: used by the C preprocessor.
26 ?C: This macro catenates 2 tokens together.
29 ?C: This macro catenates 3 tokens together.
32 ?C: This macro catenates 4 tokens together.
35 ?C: This macro catenates 5 tokens together.
38 ?C: This macro surrounds its token with double quotes.
41 ?C: This macro catenates 2 tokens together and stringifies the result.
42 ?C: It might not exist, so #ifdef it in your code!
45 ?C: This macro catenates 3 tokens together and stringifies the result.
46 ?C: It might not exist, so #ifdef it in your code!
49 ?C: This macro catenates 4 tokens together and stringifies the result.
50 ?C: It might not exist, so #ifdef it in your code!
53 ?C: This macro catenates 5 tokens together and stringifies the result.
54 ?C: It might not exist, so #ifdef it in your code!
56 ?X: Dist pl70 included the following, but AIX's xlc compiler
57 ?X: (which is ANSI-ish and has cpp_stuff == 42)) rejects
58 ?X: The SQuoTe/EQuoTe stuff because the string literals are on
59 ?X: separate lines. Sigh.
60 ?X: Andy Dougherty 24 Feb 1998
61 ?X: ?H:?%<:#if $cpp_stuff == 1
62 ?X: ?H:?CAT2:#define CAT2(a,b)a/**/b
63 ?X: ?H:?CAT3:#define CAT3(a,b,c)a/**/b/**/c
64 ?X: ?H:?CAT4:#define CAT4(a,b,c,d)a/**/b/**/c/**/d
65 ?X: ?H:?CAT5:#define CAT5(a,b,c,d,e)a/**/b/**/c/**/d/**/e
66 ?X: ?H:?STRINGIFY:#define STRINGIFY(a)"a"
67 ?X: ?H:?%<:#define SQuoTe(a)"a
68 ?X: ?H:?%<:#define EQuoTe(a)a"
69 ?X: ?H:?SCAT2:#define SCAT2(a,b)EQuoTe(SQuoTe(a)b)
70 ?X: ?H:?SCAT3:#define SCAT3(a,b,c)EQuoTe(SQuoTe(a)b/**/c)
71 ?X: ?H:?SCAT4:#define SCAT4(a,b,c,d)EQuoTe(SQuoTe(a)b/**/c/**/d)
72 ?X: ?H:?SCAT5:#define SCAT5(a,b,c,d,e)EQuoTe(SQuoTe(a)b/**/c/**/d/**/e)
74 ?H:?%<:#if $cpp_stuff == 1
75 ?H:?CAT2:#define CAT2(a,b)a/**/b
76 ?H:?CAT3#define CAT3(a,b,c)a/**/b/**/c
77 ?H:?CAT4:#define CAT4(a,b,c,d)a/**/b/**/c/**/d
78 ?H:?CAT5:#define CAT5(a,b,c,d,e)a/**/b/**/c/**/d/**/e
79 ?H:?STRINGIFY:#define STRINGIFY(a)"a"
80 ?H:?%<: /* If you can get stringification with catify, tell me how! */
82 ?H:?%<:#if $cpp_stuff == 42
83 ?H:?CAT2:#define CAT2(a,b)a ## b
84 ?H:?CAT3:#define CAT3(a,b,c)a ## b ## c
85 ?H:?CAT4:#define CAT4(a,b,c,d)a ## b ## c ## d
86 ?H:?CAT5:#define CAT5(a,b,c,d,e)a ## b ## c ## d ## e
87 ?H:?%<:#define StGiFy(a)# a
88 ?H:?STRINGIFY:#define STRINGIFY(a)StGiFy(a)
89 ?H:?SCAT2:#define SCAT2(a,b)StGiFy(a) StGiFy(b)
90 ?H:?SCAT3:#define SCAT3(a,b,c)StGiFy(a) StGiFy(b) StGiFy(c)
91 ?H:?SCAT4:#define SCAT4(a,b,c,d)StGiFy(a) StGiFy(b) StGiFy(c) StGiFy(d)
92 ?H:?SCAT5:#define SCAT5(a,b,c,d,e)StGiFy(a) StGiFy(b) StGiFy(c) StGiFy(d) StGiFy(e)
94 ?H:?%<:#if $cpp_stuff != 1 && $cpp_stuff != 42
95 ?H:?%<:#include "Bletch: How does this C preprocessor catenate tokens?"
98 ?W:%<:CAT2 CAT3 CAT4 CAT5 STRINGIFY SCAT2 SCAT3 SCAT4 SCAT5
100 : how do we catenate cpp tokens here?
102 echo "Checking to see how your cpp does stuff like catenate tokens..." >&4
103 $cat >cpp_stuff.c <<'EOCP'
104 #define RCAT(a,b)a/**/b
105 #define ACAT(a,b)a ## b
109 $cppstdin $cppflags $cppminus <cpp_stuff.c >cpp_stuff.out 2>&1
110 if $contains 'Circus' cpp_stuff.out >/dev/null 2>&1; then
111 echo "Oh! Smells like ANSI's been here." >&4
112 echo "We can catify or stringify, separately or together!"
114 elif $contains 'Reiser' cpp_stuff.out >/dev/null 2>&1; then
115 echo "Ah, yes! The good old days!" >&4
116 echo "However, in the good old days we don't know how to stringify and"
117 echo "catify at the same time."
121 Hmm, I don't seem to be able to catenate tokens with your cpp. You're going
122 to have to edit the values of CAT[2-5] in config.h...
124 ?X: It would be nice to have configure remind us at the end that some manual
125 ?X: intervention is needed -- FIXME
126 cpp_stuff="/* Help! How do we handle cpp_stuff? */*/"