build.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/build.h
  3. // Purpose: Runtime build options checking
  4. // Author: Vadim Zeitlin, Vaclav Slavik
  5. // Modified by:
  6. // Created: 07.05.02
  7. // Copyright: (c) 2002 Vadim Zeitlin <vadim@wxwidgets.org>
  8. // Licence: wxWindows licence
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_BUILD_H_
  11. #define _WX_BUILD_H_
  12. #include "wx/version.h"
  13. // NB: This file contains macros for checking binary compatibility of libraries
  14. // in multilib builds, plugins and user components.
  15. // The WX_BUILD_OPTIONS_SIGNATURE macro expands into string that should
  16. // uniquely identify binary compatible builds: i.e. if two builds of the
  17. // library are binary compatible, their signature string should be the
  18. // same; if two builds are binary incompatible, their signatures should
  19. // be different.
  20. //
  21. // Therefore, wxUSE_XXX flags that affect binary compatibility (vtables,
  22. // function signatures) should be accounted for here. So should compilers
  23. // and compiler versions (but note that binary compatible compiler versions
  24. // such as gcc-2.95.2 and gcc-2.95.3 should have same signature!).
  25. // ----------------------------------------------------------------------------
  26. // WX_BUILD_OPTIONS_SIGNATURE
  27. // ----------------------------------------------------------------------------
  28. #define __WX_BO_STRINGIZE(x) __WX_BO_STRINGIZE0(x)
  29. #define __WX_BO_STRINGIZE0(x) #x
  30. #if (wxMINOR_VERSION % 2) == 0
  31. #define __WX_BO_VERSION(x,y,z) \
  32. __WX_BO_STRINGIZE(x) "." __WX_BO_STRINGIZE(y)
  33. #else
  34. #define __WX_BO_VERSION(x,y,z) \
  35. __WX_BO_STRINGIZE(x) "." __WX_BO_STRINGIZE(y) "." __WX_BO_STRINGIZE(z)
  36. #endif
  37. #if wxUSE_UNICODE_UTF8
  38. #define __WX_BO_UNICODE "UTF-8"
  39. #elif wxUSE_UNICODE_WCHAR
  40. #define __WX_BO_UNICODE "wchar_t"
  41. #else
  42. #define __WX_BO_UNICODE "ANSI"
  43. #endif
  44. // GCC and Intel C++ share same C++ ABI (and possibly others in the future),
  45. // check if compiler versions are compatible:
  46. #if defined(__GXX_ABI_VERSION)
  47. #define __WX_BO_COMPILER \
  48. ",compiler with C++ ABI " __WX_BO_STRINGIZE(__GXX_ABI_VERSION)
  49. #elif defined(__INTEL_COMPILER)
  50. #define __WX_BO_COMPILER ",Intel C++"
  51. #elif defined(__GNUG__)
  52. #define __WX_BO_COMPILER ",GCC " \
  53. __WX_BO_STRINGIZE(__GNUC__) "." __WX_BO_STRINGIZE(__GNUC_MINOR__)
  54. #elif defined(__VISUALC__)
  55. #define __WX_BO_COMPILER ",Visual C++ " __WX_BO_STRINGIZE(_MSC_VER)
  56. #elif defined(__BORLANDC__)
  57. #define __WX_BO_COMPILER ",Borland C++"
  58. #elif defined(__DIGITALMARS__)
  59. #define __WX_BO_COMPILER ",DigitalMars"
  60. #elif defined(__WATCOMC__)
  61. #define __WX_BO_COMPILER ",Watcom C++"
  62. #else
  63. #define __WX_BO_COMPILER
  64. #endif
  65. // WXWIN_COMPATIBILITY macros affect presence of virtual functions
  66. #if WXWIN_COMPATIBILITY_2_6
  67. #define __WX_BO_WXWIN_COMPAT_2_6 ",compatible with 2.6"
  68. #else
  69. #define __WX_BO_WXWIN_COMPAT_2_6
  70. #endif
  71. #if WXWIN_COMPATIBILITY_2_8
  72. #define __WX_BO_WXWIN_COMPAT_2_8 ",compatible with 2.8"
  73. #else
  74. #define __WX_BO_WXWIN_COMPAT_2_8
  75. #endif
  76. // deriving wxWin containers from STL ones changes them completely:
  77. #if wxUSE_STD_CONTAINERS
  78. #define __WX_BO_STL ",STL containers"
  79. #else
  80. #define __WX_BO_STL ",wx containers"
  81. #endif
  82. // This macro is passed as argument to wxConsoleApp::CheckBuildOptions()
  83. #define WX_BUILD_OPTIONS_SIGNATURE \
  84. __WX_BO_VERSION(wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER) \
  85. " (" __WX_BO_UNICODE \
  86. __WX_BO_COMPILER \
  87. __WX_BO_STL \
  88. __WX_BO_WXWIN_COMPAT_2_6 __WX_BO_WXWIN_COMPAT_2_8 \
  89. ")"
  90. // ----------------------------------------------------------------------------
  91. // WX_CHECK_BUILD_OPTIONS
  92. // ----------------------------------------------------------------------------
  93. // Use this macro to check build options. Adding it to a file in DLL will
  94. // ensure that the DLL checks build options in same way wxIMPLEMENT_APP() does.
  95. #define WX_CHECK_BUILD_OPTIONS(libName) \
  96. static struct wxBuildOptionsChecker \
  97. { \
  98. wxBuildOptionsChecker() \
  99. { \
  100. wxAppConsole::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, \
  101. libName); \
  102. } \
  103. } gs_buildOptionsCheck;
  104. #endif // _WX_BUILD_H_