/[gnats]/gnats/include/symcat.h
ViewVC logotype

Diff of /gnats/include/symcat.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by jsm, Tue Oct 26 07:10:16 1999 UTC revision 1.2 by chewie, Sat Nov 13 05:14:17 2004 UTC
# Line 1  Line 1 
1  /* Symbol concatenation utilities.  /* Symbol concatenation utilities.
2    
3     Copyright (C) 1998, Free Software Foundation, Inc.     Copyright (C) 1998, 2000 Free Software Foundation, Inc.
4    
5     This program is free software; you can redistribute it and/or modify     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     it under the terms of the GNU General Public License as published by
# Line 19  Line 19 
19  #ifndef SYM_CAT_H  #ifndef SYM_CAT_H
20  #define SYM_CAT_H  #define SYM_CAT_H
21    
22  #if defined (__STDC__) || defined (ALMOST_STDC)  #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
23  #define CONCAT2(a,b)     a##b  #define CONCAT2(a,b)     a##b
24  #define CONCAT3(a,b,c)   a##b##c  #define CONCAT3(a,b,c)   a##b##c
25  #define CONCAT4(a,b,c,d) a##b##c##d  #define CONCAT4(a,b,c,d) a##b##c##d
26  #define STRINGX(s) #s  #define STRINGX(s) #s
27  #else  #else
28    /* Note one should never pass extra whitespace to the CONCATn macros,
29       e.g. CONCAT2(foo, bar) because traditonal C will keep the space between
30       the two labels instead of concatenating them.  Instead, make sure to
31       write CONCAT2(foo,bar).  */
32  #define CONCAT2(a,b)     a/**/b  #define CONCAT2(a,b)     a/**/b
33  #define CONCAT3(a,b,c)   a/**/b/**/c  #define CONCAT3(a,b,c)   a/**/b/**/c
34  #define CONCAT4(a,b,c,d) a/**/b/**/c/**/d  #define CONCAT4(a,b,c,d) a/**/b/**/c/**/d
35  #define STRINGX(s) "?"  #define STRINGX(s) "s"
36  #endif  #endif
37    
38  #define XCONCAT2(a,b)     CONCAT2(a,b)  #define XCONCAT2(a,b)     CONCAT2(a,b)
39  #define XCONCAT3(a,b,c)   CONCAT3(a,b,c)  #define XCONCAT3(a,b,c)   CONCAT3(a,b,c)
40  #define XCONCAT4(a,b,c,d) CONCAT4(a,b,c,d)  #define XCONCAT4(a,b,c,d) CONCAT4(a,b,c,d)
41    
42    /* Note the layer of indirection here is typically used to allow
43       stringification of the expansion of macros.  I.e. "#define foo
44       bar", "XSTRING(foo)", to yield "bar".  Be aware that this only
45       works for __STDC__, not for traditional C which will still resolve
46       to "foo".  */
47  #define XSTRING(s) STRINGX(s)  #define XSTRING(s) STRINGX(s)
48    
49  #endif SYM_CAT_H  #endif /* SYM_CAT_H */

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26