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