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