PageRenderTime 44ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/ExtLibs/wxWidgets/include/wx/cpp.h

https://bitbucket.org/lennonchan/cafu
C Header | 93 lines | 34 code | 13 blank | 46 comment | 4 complexity | 8effc2264e54fc97af2b7acbb7e3c803 MD5 | raw file
  1. /*
  2. * Name: wx/cpp.h
  3. * Purpose: Various preprocessor helpers
  4. * Author: Vadim Zeitlin
  5. * Created: 2006-09-30
  6. * RCS-ID: $Id$
  7. * Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
  8. * Licence: wxWindows licence
  9. */
  10. /* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */
  11. #ifndef _WX_CPP_H_
  12. #define _WX_CPP_H_
  13. /* wxCONCAT works like preprocessor ## operator but also works with macros */
  14. #define wxCONCAT_HELPER(text, line) text ## line
  15. #define wxCONCAT(text, line) wxCONCAT_HELPER(text, line)
  16. #define wxCONCAT3(x1, x2, x3) wxCONCAT(wxCONCAT(x1, x2), x3)
  17. #define wxCONCAT4(x1, x2, x3, x4) wxCONCAT(wxCONCAT3(x1, x2, x3), x4)
  18. #define wxCONCAT5(x1, x2, x3, x4, x5) wxCONCAT(wxCONCAT4(x1, x2, x3, x4), x5)
  19. /* wxSTRINGIZE works as the preprocessor # operator but also works with macros */
  20. #define wxSTRINGIZE_HELPER(x) #x
  21. #define wxSTRINGIZE(x) wxSTRINGIZE_HELPER(x)
  22. /* a Unicode-friendly version of wxSTRINGIZE_T */
  23. #define wxSTRINGIZE_T(x) wxAPPLY_T(wxSTRINGIZE(x))
  24. /*
  25. Special workarounds for compilers with broken "##" operator. For all the
  26. other ones we can just use it directly.
  27. */
  28. #ifdef wxCOMPILER_BROKEN_CONCAT_OPER
  29. #define wxPREPEND_L(x) L ## x
  30. #define wxAPPEND_i64(x) x ## i64
  31. #define wxAPPEND_ui64(x) x ## ui64
  32. #endif /* wxCOMPILER_BROKEN_CONCAT_OPER */
  33. /*
  34. Helper macros for wxMAKE_UNIQUE_NAME: normally this works by appending the
  35. current line number to the given identifier to reduce the probability of the
  36. conflict (it may still happen if this is used in the headers, hence you
  37. should avoid doing it or provide unique prefixes then) but we have to do it
  38. differently for VC++
  39. */
  40. #if defined(__VISUALC__) && (__VISUALC__ >= 1300)
  41. /*
  42. __LINE__ handling is completely broken in VC++ when using "Edit and
  43. Continue" (/ZI option) and results in preprocessor errors if we use it
  44. inside the macros. Luckily VC7 has another standard macro which can be
  45. used like this and is even better than __LINE__ because it is globally
  46. unique.
  47. */
  48. # define wxCONCAT_LINE(text) wxCONCAT(text, __COUNTER__)
  49. #else /* normal compilers */
  50. # define wxCONCAT_LINE(text) wxCONCAT(text, __LINE__)
  51. #endif
  52. /* Create a "unique" name with the given prefix */
  53. #define wxMAKE_UNIQUE_NAME(text) wxCONCAT_LINE(text)
  54. /*
  55. This macro can be passed as argument to another macro when you don't have
  56. anything to pass in fact.
  57. */
  58. #define wxEMPTY_PARAMETER_VALUE /* Fake macro parameter value */
  59. /*
  60. Define __WXFUNCTION__ which is like standard __FUNCTION__ but defined as
  61. NULL for the compilers which don't support the latter.
  62. */
  63. #ifndef __WXFUNCTION__
  64. /* TODO: add more compilers supporting __FUNCTION__ */
  65. #if defined(__DMC__)
  66. /*
  67. __FUNCTION__ happens to be not defined within class members
  68. http://www.digitalmars.com/drn-bin/wwwnews?c%2B%2B.beta/485
  69. */
  70. #define __WXFUNCTION__ (NULL)
  71. #elif defined(__GNUC__) || \
  72. (defined(_MSC_VER) && _MSC_VER >= 1300) || \
  73. defined(__FUNCTION__)
  74. #define __WXFUNCTION__ __FUNCTION__
  75. #else
  76. /* still define __WXFUNCTION__ to avoid #ifdefs elsewhere */
  77. #define __WXFUNCTION__ (NULL)
  78. #endif
  79. #endif /* __WXFUNCTION__ already defined */
  80. #endif /* _WX_CPP_H_ */