build.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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(__GNUG__)
  50. #define __WX_BO_COMPILER ",GCC " \
  51. __WX_BO_STRINGIZE(__GNUC__) "." __WX_BO_STRINGIZE(__GNUC_MINOR__)
  52. #elif defined(__VISUALC__)
  53. #define __WX_BO_COMPILER ",Visual C++ " __WX_BO_STRINGIZE(_MSC_VER)
  54. #elif defined(__INTEL_COMPILER)
  55. // Notice that this must come after MSVC check as ICC under Windows is
  56. // ABI-compatible with the corresponding version of the MSVC and we want to
  57. // allow using it compile the application code using MSVC-built DLLs.
  58. #define __WX_BO_COMPILER ",Intel C++"
  59. #elif defined(__BORLANDC__)
  60. #define __WX_BO_COMPILER ",Borland C++"
  61. #elif defined(__DIGITALMARS__)
  62. #define __WX_BO_COMPILER ",DigitalMars"
  63. #elif defined(__WATCOMC__)
  64. #define __WX_BO_COMPILER ",Watcom C++"
  65. #else
  66. #define __WX_BO_COMPILER
  67. #endif
  68. // WXWIN_COMPATIBILITY macros affect presence of virtual functions
  69. #if WXWIN_COMPATIBILITY_2_6
  70. #define __WX_BO_WXWIN_COMPAT_2_6 ",compatible with 2.6"
  71. #else
  72. #define __WX_BO_WXWIN_COMPAT_2_6
  73. #endif
  74. #if WXWIN_COMPATIBILITY_2_8
  75. #define __WX_BO_WXWIN_COMPAT_2_8 ",compatible with 2.8"
  76. #else
  77. #define __WX_BO_WXWIN_COMPAT_2_8
  78. #endif
  79. // deriving wxWin containers from STL ones changes them completely:
  80. #if wxUSE_STD_CONTAINERS
  81. #define __WX_BO_STL ",STL containers"
  82. #else
  83. #define __WX_BO_STL ",wx containers"
  84. #endif
  85. // This macro is passed as argument to wxConsoleApp::CheckBuildOptions()
  86. #define WX_BUILD_OPTIONS_SIGNATURE \
  87. __WX_BO_VERSION(wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER) \
  88. " (" __WX_BO_UNICODE \
  89. __WX_BO_COMPILER \
  90. __WX_BO_STL \
  91. __WX_BO_WXWIN_COMPAT_2_6 __WX_BO_WXWIN_COMPAT_2_8 \
  92. ")"
  93. // ----------------------------------------------------------------------------
  94. // WX_CHECK_BUILD_OPTIONS
  95. // ----------------------------------------------------------------------------
  96. // Use this macro to check build options. Adding it to a file in DLL will
  97. // ensure that the DLL checks build options in same way wxIMPLEMENT_APP() does.
  98. #define WX_CHECK_BUILD_OPTIONS(libName) \
  99. static struct wxBuildOptionsChecker \
  100. { \
  101. wxBuildOptionsChecker() \
  102. { \
  103. wxAppConsole::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, \
  104. libName); \
  105. } \
  106. } gs_buildOptionsCheck;
  107. #endif // _WX_BUILD_H_