poison.hpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. // Copyright John Maddock 2013.
  2. // Use, modification and distribution are subject to the
  3. // Boost Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef BOOST_MATH_COMPILE_POISON_HPP
  6. #define BOOST_MATH_COMPILE_POISON_HPP
  7. #include <cmath>
  8. #include <math.h>
  9. //
  10. // As per https://github.com/boostorg/math/issues/126
  11. // we basically need to include every std lib header we use, otherwise
  12. // our poisoned macros can break legit std lib code.
  13. //
  14. #include <boost/config.hpp>
  15. #include <valarray>
  16. #include <complex>
  17. #include <iosfwd>
  18. #include <sstream>
  19. #include <ostream>
  20. #include <istream>
  21. #include <utility>
  22. #include <iomanip>
  23. #include <typeinfo>
  24. #include <stdexcept>
  25. #include <cstddef>
  26. #include <string>
  27. #include <cstring>
  28. #include <cctype>
  29. #include <limits>
  30. #include <exception>
  31. #include <iterator>
  32. #include <numeric>
  33. #include <vector>
  34. #include <algorithm>
  35. #include <typeinfo>
  36. #include <memory>
  37. #include <cerrno>
  38. #include <functional>
  39. #ifndef BOOST_NO_CXX11_HDR_FUTURE
  40. #include <future>
  41. #endif
  42. #ifndef BOOST_NO_CXX11_HDR_THREAD
  43. #include <thread>
  44. #endif
  45. #ifndef BOOST_NO_CXX11_HDR_RANDOM
  46. #include <random>
  47. #endif
  48. #ifndef BOOST_NO_CXX11_HDR_CHRONO
  49. #include <chrono>
  50. #endif
  51. #include <map>
  52. //
  53. // We have to include this *before* poisoning the macros
  54. // as it needs to be able to use them!
  55. //
  56. #include <boost/math/special_functions/fpclassify.hpp>
  57. //
  58. // Poison all the function-like macros in C99 so if we accidentally call them
  59. // in an unsafe manner, we'll get compiler errors. Of course these shouldn't be
  60. // macros in C++ at all...
  61. //
  62. #ifdef fpclassify
  63. #undef fpclassify
  64. #endif
  65. #define fpclassify(x) this_should_not_compile(x)}}}}}}}}}}}}}}}}}}}
  66. #ifdef isfinite
  67. #undef isfinite
  68. #endif
  69. #define isfinite(x) this_should_not_compile(x)}}}}}}}}}}}}}}}}}}}
  70. #ifdef isinf
  71. #undef isinf
  72. #endif
  73. #define isinf(x) this_should_not_compile(x)}}}}}}}}}}}}}}}}}}}
  74. #ifdef isnan
  75. #undef isnan
  76. #endif
  77. #define isnan(x) this_should_not_compile(x)}}}}}}}}}}}}}}}}}}}
  78. #ifdef isnormal
  79. #undef isnormal
  80. #endif
  81. #define isnormal(x) this_should_not_compile(x)}}}}}}}}}}}}}}}}}}}
  82. #ifdef signbit
  83. #undef signbit
  84. #endif
  85. #define signbit(x) this_should_not_compile(x)}}}}}}}}}}}}}}}}}}}
  86. #ifdef isgreater
  87. #undef isgreater
  88. #endif
  89. #define isgreater(x) this_should_not_compile(x)}}}}}}}}}}}}}}}}}}}
  90. #ifdef isgreaterequal
  91. #undef isgreaterequal
  92. #endif
  93. #define isgreaterequal(x) this_should_not_compile(x)}}}}}}}}}}}}}}}}}}}
  94. #ifdef isless
  95. #undef isless
  96. #endif
  97. #define isless(x) this_should_not_compile(x)}}}}}}}}}}}}}}}}}}}
  98. #ifdef islessequal
  99. #undef islessequal
  100. #endif
  101. #define islessequal(x) this_should_not_compile(x)}}}}}}}}}}}}}}}}}}}
  102. #ifdef islessgreater
  103. #undef islessgreater
  104. #endif
  105. #define islessgreater(x) this_should_not_compile(x)}}}}}}}}}}}}}}}}}}}
  106. #ifdef isunordered
  107. #undef isunordered
  108. #endif
  109. #define isunordered(x) this_should_not_compile(x)}}}}}}}}}}}}}}}}}}}
  110. #endif