xref: /dragonfly/contrib/gcc-4.7/include/symcat.h (revision e4b17023)
1*e4b17023SJohn Marino /* Symbol concatenation utilities.
2*e4b17023SJohn Marino 
3*e4b17023SJohn Marino    Copyright (C) 1998, 2000, 2010 Free Software Foundation, Inc.
4*e4b17023SJohn Marino 
5*e4b17023SJohn Marino    This program is free software; you can redistribute it and/or modify
6*e4b17023SJohn Marino    it under the terms of the GNU General Public License as published by
7*e4b17023SJohn Marino    the Free Software Foundation; either version 2 of the License, or
8*e4b17023SJohn Marino    (at your option) any later version.
9*e4b17023SJohn Marino 
10*e4b17023SJohn Marino    This program is distributed in the hope that it will be useful,
11*e4b17023SJohn Marino    but WITHOUT ANY WARRANTY; without even the implied warranty of
12*e4b17023SJohn Marino    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13*e4b17023SJohn Marino    GNU General Public License for more details.
14*e4b17023SJohn Marino 
15*e4b17023SJohn Marino    You should have received a copy of the GNU General Public License along
16*e4b17023SJohn Marino    with this program; if not, write to the Free Software Foundation, Inc.,
17*e4b17023SJohn Marino    51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
18*e4b17023SJohn Marino 
19*e4b17023SJohn Marino #ifndef SYM_CAT_H
20*e4b17023SJohn Marino #define SYM_CAT_H
21*e4b17023SJohn Marino 
22*e4b17023SJohn Marino #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
23*e4b17023SJohn Marino #define CONCAT2(a,b)	 a##b
24*e4b17023SJohn Marino #define CONCAT3(a,b,c)	 a##b##c
25*e4b17023SJohn Marino #define CONCAT4(a,b,c,d) a##b##c##d
26*e4b17023SJohn Marino #define CONCAT5(a,b,c,d,e) a##b##c##d##e
27*e4b17023SJohn Marino #define CONCAT6(a,b,c,d,e,f) a##b##c##d##e##f
28*e4b17023SJohn Marino #define STRINGX(s) #s
29*e4b17023SJohn Marino #else
30*e4b17023SJohn Marino /* Note one should never pass extra whitespace to the CONCATn macros,
31*e4b17023SJohn Marino    e.g. CONCAT2(foo, bar) because traditonal C will keep the space between
32*e4b17023SJohn Marino    the two labels instead of concatenating them.  Instead, make sure to
33*e4b17023SJohn Marino    write CONCAT2(foo,bar).  */
34*e4b17023SJohn Marino #define CONCAT2(a,b)	 a/**/b
35*e4b17023SJohn Marino #define CONCAT3(a,b,c)	 a/**/b/**/c
36*e4b17023SJohn Marino #define CONCAT4(a,b,c,d) a/**/b/**/c/**/d
37*e4b17023SJohn Marino #define CONCAT5(a,b,c,d,e) a/**/b/**/c/**/d/**/e
38*e4b17023SJohn Marino #define CONCAT6(a,b,c,d,e,f) a/**/b/**/c/**/d/**/e/**/f
39*e4b17023SJohn Marino #define STRINGX(s) "s"
40*e4b17023SJohn Marino #endif
41*e4b17023SJohn Marino 
42*e4b17023SJohn Marino #define XCONCAT2(a,b)     CONCAT2(a,b)
43*e4b17023SJohn Marino #define XCONCAT3(a,b,c)   CONCAT3(a,b,c)
44*e4b17023SJohn Marino #define XCONCAT4(a,b,c,d) CONCAT4(a,b,c,d)
45*e4b17023SJohn Marino #define XCONCAT5(a,b,c,d,e) CONCAT5(a,b,c,d,e)
46*e4b17023SJohn Marino #define XCONCAT6(a,b,c,d,e,f) CONCAT6(a,b,c,d,e,f)
47*e4b17023SJohn Marino 
48*e4b17023SJohn Marino /* Note the layer of indirection here is typically used to allow
49*e4b17023SJohn Marino    stringification of the expansion of macros.  I.e. "#define foo
50*e4b17023SJohn Marino    bar", "XSTRING(foo)", to yield "bar".  Be aware that this only
51*e4b17023SJohn Marino    works for __STDC__, not for traditional C which will still resolve
52*e4b17023SJohn Marino    to "foo".  */
53*e4b17023SJohn Marino #define XSTRING(s) STRINGX(s)
54*e4b17023SJohn Marino 
55*e4b17023SJohn Marino #endif /* SYM_CAT_H */
56