symcat.h 1.9 KB

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