symcat.h revision 169696
1254885Sdumbbell/* Symbol concatenation utilities. 2254885Sdumbbell 3254885Sdumbbell Copyright (C) 1998, 2000 Free Software Foundation, Inc. 4254885Sdumbbell 5254885Sdumbbell This program is free software; you can redistribute it and/or modify 6254885Sdumbbell it under the terms of the GNU General Public License as published by 7254885Sdumbbell the Free Software Foundation; either version 2 of the License, or 8254885Sdumbbell (at your option) any later version. 9254885Sdumbbell 10254885Sdumbbell This program is distributed in the hope that it will be useful, 11254885Sdumbbell but WITHOUT ANY WARRANTY; without even the implied warranty of 12254885Sdumbbell MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13254885Sdumbbell GNU General Public License for more details. 14254885Sdumbbell 15254885Sdumbbell You should have received a copy of the GNU General Public License along 16254885Sdumbbell with this program; if not, write to the Free Software Foundation, Inc., 17254885Sdumbbell 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ 18254885Sdumbbell 19254885Sdumbbell#ifndef SYM_CAT_H 20254885Sdumbbell#define SYM_CAT_H 21254885Sdumbbell 22254885Sdumbbell#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) 23254885Sdumbbell#define CONCAT2(a,b) a##b 24254885Sdumbbell#define CONCAT3(a,b,c) a##b##c 25254885Sdumbbell#define CONCAT4(a,b,c,d) a##b##c##d 26254885Sdumbbell#define STRINGX(s) #s 27254885Sdumbbell#else 28254885Sdumbbell/* Note one should never pass extra whitespace to the CONCATn macros, 29254885Sdumbbell e.g. CONCAT2(foo, bar) because traditonal C will keep the space between 30254885Sdumbbell the two labels instead of concatenating them. Instead, make sure to 31254885Sdumbbell write CONCAT2(foo,bar). */ 32254885Sdumbbell#define CONCAT2(a,b) a/**/b 33254885Sdumbbell#define CONCAT3(a,b,c) a/**/b/**/c 34254885Sdumbbell#define CONCAT4(a,b,c,d) a/**/b/**/c/**/d 35254885Sdumbbell#define STRINGX(s) "s" 36254885Sdumbbell#endif 37254885Sdumbbell 38254885Sdumbbell#define XCONCAT2(a,b) CONCAT2(a,b) 39254885Sdumbbell#define XCONCAT3(a,b,c) CONCAT3(a,b,c) 40254885Sdumbbell#define XCONCAT4(a,b,c,d) CONCAT4(a,b,c,d) 41254885Sdumbbell 42254885Sdumbbell/* Note the layer of indirection here is typically used to allow 43254885Sdumbbell stringification of the expansion of macros. I.e. "#define foo 44254885Sdumbbell bar", "XSTRING(foo)", to yield "bar". Be aware that this only 45254885Sdumbbell works for __STDC__, not for traditional C which will still resolve 46254885Sdumbbell to "foo". */ 47254885Sdumbbell#define XSTRING(s) STRINGX(s) 48254885Sdumbbell 49254885Sdumbbell#endif /* SYM_CAT_H */ 50254885Sdumbbell