14fee23f9Smrg /* Symbol concatenation utilities. 24fee23f9Smrg 3*b1e83836Smrg Copyright (C) 1998-2022 Free Software Foundation, Inc. 44fee23f9Smrg 54fee23f9Smrg This program is free software; you can redistribute it and/or modify 64fee23f9Smrg it under the terms of the GNU General Public License as published by 74fee23f9Smrg the Free Software Foundation; either version 2 of the License, or 84fee23f9Smrg (at your option) any later version. 94fee23f9Smrg 104fee23f9Smrg This program is distributed in the hope that it will be useful, 114fee23f9Smrg but WITHOUT ANY WARRANTY; without even the implied warranty of 124fee23f9Smrg MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 134fee23f9Smrg GNU General Public License for more details. 144fee23f9Smrg 154fee23f9Smrg You should have received a copy of the GNU General Public License along 164fee23f9Smrg with this program; if not, write to the Free Software Foundation, Inc., 174fee23f9Smrg 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ 184fee23f9Smrg 194fee23f9Smrg #ifndef SYM_CAT_H 204fee23f9Smrg #define SYM_CAT_H 214fee23f9Smrg 224fee23f9Smrg #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) 234fee23f9Smrg #define CONCAT2(a,b) a##b 244fee23f9Smrg #define CONCAT3(a,b,c) a##b##c 254fee23f9Smrg #define CONCAT4(a,b,c,d) a##b##c##d 264fee23f9Smrg #define CONCAT5(a,b,c,d,e) a##b##c##d##e 274fee23f9Smrg #define CONCAT6(a,b,c,d,e,f) a##b##c##d##e##f 284fee23f9Smrg #define STRINGX(s) #s 294fee23f9Smrg #else 304fee23f9Smrg /* Note one should never pass extra whitespace to the CONCATn macros, 314fee23f9Smrg e.g. CONCAT2(foo, bar) because traditonal C will keep the space between 324fee23f9Smrg the two labels instead of concatenating them. Instead, make sure to 334fee23f9Smrg write CONCAT2(foo,bar). */ 344fee23f9Smrg #define CONCAT2(a,b) a/**/b 354fee23f9Smrg #define CONCAT3(a,b,c) a/**/b/**/c 364fee23f9Smrg #define CONCAT4(a,b,c,d) a/**/b/**/c/**/d 374fee23f9Smrg #define CONCAT5(a,b,c,d,e) a/**/b/**/c/**/d/**/e 384fee23f9Smrg #define CONCAT6(a,b,c,d,e,f) a/**/b/**/c/**/d/**/e/**/f 394fee23f9Smrg #define STRINGX(s) "s" 404fee23f9Smrg #endif 414fee23f9Smrg 424fee23f9Smrg #define XCONCAT2(a,b) CONCAT2(a,b) 434fee23f9Smrg #define XCONCAT3(a,b,c) CONCAT3(a,b,c) 444fee23f9Smrg #define XCONCAT4(a,b,c,d) CONCAT4(a,b,c,d) 454fee23f9Smrg #define XCONCAT5(a,b,c,d,e) CONCAT5(a,b,c,d,e) 464fee23f9Smrg #define XCONCAT6(a,b,c,d,e,f) CONCAT6(a,b,c,d,e,f) 474fee23f9Smrg 484fee23f9Smrg /* Note the layer of indirection here is typically used to allow 494fee23f9Smrg stringification of the expansion of macros. I.e. "#define foo 504fee23f9Smrg bar", "XSTRING(foo)", to yield "bar". Be aware that this only 514fee23f9Smrg works for __STDC__, not for traditional C which will still resolve 524fee23f9Smrg to "foo". */ 534fee23f9Smrg #define XSTRING(s) STRINGX(s) 544fee23f9Smrg 554fee23f9Smrg #endif /* SYM_CAT_H */ 56