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