workaround.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. Copyright Rene Rivera 2017
  3. Distributed under the Boost Software License, Version 1.0.
  4. (See accompanying file LICENSE_1_0.txt or copy at
  5. http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. #ifndef BOOST_PREDEF_WORKAROUND_H
  8. #define BOOST_PREDEF_WORKAROUND_H
  9. /*`
  10. [heading `BOOST_PREDEF_WORKAROUND`]
  11. ``
  12. BOOST_PREDEF_WORKAROUND(symbol,comp,major,minor,patch)
  13. ``
  14. Usage:
  15. ``
  16. #if BOOST_PREDEF_WORKAROUND(BOOST_COMP_CLANG,<,3,0,0)
  17. // Workaround for old clang compilers..
  18. #endif
  19. ``
  20. Defines a comparison against two version numbers that depends on the definion
  21. of `BOOST_STRICT_CONFIG`. When `BOOST_STRICT_CONFIG` is defined this will expand
  22. to a value convertible to `false`. Which has the effect of disabling all code
  23. conditionally guarded by `BOOST_PREDEF_WORKAROUND`. When `BOOST_STRICT_CONFIG`
  24. is undefine this expand to test the given `symbol` version value with the
  25. `comp` comparison against `BOOST_VERSION_NUMBER(major,minor,patch)`.
  26. */
  27. #ifdef BOOST_STRICT_CONFIG
  28. # define BOOST_PREDEF_WORKAROUND(symbol, comp, major, minor, patch) (0)
  29. #else
  30. # include <boost/predef/version_number.h>
  31. # define BOOST_PREDEF_WORKAROUND(symbol, comp, major, minor, patch) \
  32. ( (symbol) != (0) ) && \
  33. ( (symbol) comp (BOOST_VERSION_NUMBER( (major) , (minor) , (patch) )) )
  34. #endif
  35. /*`
  36. [heading `BOOST_PREDEF_TESTED_AT`]
  37. ``
  38. BOOST_PREDEF_TESTED_AT(symbol,major,minor,patch)
  39. ``
  40. Usage:
  41. ``
  42. #if BOOST_PREDEF_TESTED_AT(BOOST_COMP_CLANG,3,5,0)
  43. // Needed for clang, and last checked for 3.5.0.
  44. #endif
  45. ``
  46. Defines a comparison against two version numbers that depends on the definion
  47. of `BOOST_STRICT_CONFIG` and `BOOST_DETECT_OUTDATED_WORKAROUNDS`.
  48. When `BOOST_STRICT_CONFIG` is defined this will expand to a value convertible
  49. to `false`. Which has the effect of disabling all code
  50. conditionally guarded by `BOOST_PREDEF_TESTED_AT`. When `BOOST_STRICT_CONFIG`
  51. is undefined this expand to either:
  52. * A value convertible to `true` when `BOOST_DETECT_OUTDATED_WORKAROUNDS` is not
  53. defined.
  54. * A value convertible `true` when the expansion of
  55. `BOOST_PREDEF_WORKAROUND(symbol, <=, major, minor, patch)` is `true` and
  56. `BOOST_DETECT_OUTDATED_WORKAROUNDS` is defined.
  57. * A compile error when the expansion of
  58. `BOOST_PREDEF_WORKAROUND(symbol, >, major, minor, patch)` is true and
  59. `BOOST_DETECT_OUTDATED_WORKAROUNDS` is defined.
  60. */
  61. #ifdef BOOST_STRICT_CONFIG
  62. # define BOOST_PREDEF_TESTED_AT(symbol, major, minor, patch) (0)
  63. #else
  64. # ifdef BOOST_DETECT_OUTDATED_WORKAROUNDS
  65. # define BOOST_PREDEF_TESTED_AT(symbol, major, minor, patch) ( \
  66. BOOST_PREDEF_WORKAROUND(symbol, <=, major, minor, patch) \
  67. ? 1 \
  68. : (1%0) )
  69. # else
  70. # define BOOST_PREDEF_TESTED_AT(symbol, major, minor, patch) \
  71. ( (symbol) >= BOOST_VERSION_NUMBER_AVAILABLE )
  72. # endif
  73. #endif
  74. #endif