soci-compiler.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. //
  2. // Copyright (C) 2015 Vadim Zeitlin
  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 SOCI_PRIVATE_SOCI_COMPILER_H_INCLUDED
  8. #define SOCI_PRIVATE_SOCI_COMPILER_H_INCLUDED
  9. #include "soci-cpp.h"
  10. // SOCI_CHECK_GCC(major,minor) evaluates to 1 when using g++ of at least this
  11. // version or 0 when using g++ of lesser version or not using g++ at all.
  12. #if defined(__GNUC__) && defined(__GNUC_MINOR__)
  13. # define SOCI_CHECK_GCC(major, minor) \
  14. ((__GNUC__ > (major)) \
  15. || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
  16. #else
  17. # define SOCI_CHECK_GCC(major, minor) 0
  18. #endif
  19. // GCC_WARNING_{SUPPRESS,RESTORE} macros can be used to bracket the code
  20. // producing a specific warning to disable it.
  21. //
  22. // They only work with g++ 4.6+ or clang, warnings are not disabled for earlier
  23. // g++ versions.
  24. #if defined(__clang__) || SOCI_CHECK_GCC(4, 6)
  25. # define SOCI_GCC_WARNING_SUPPRESS(x) \
  26. _Pragma (SOCI_STRINGIZE(GCC diagnostic push)) \
  27. _Pragma (SOCI_STRINGIZE(GCC diagnostic ignored SOCI_STRINGIZE(SOCI_CONCAT(-W,x))))
  28. # define SOCI_GCC_WARNING_RESTORE(x) \
  29. _Pragma (SOCI_STRINGIZE(GCC diagnostic pop))
  30. #else /* gcc < 4.6 or not gcc and not clang at all */
  31. # define SOCI_GCC_WARNING_SUPPRESS(x)
  32. # define SOCI_GCC_WARNING_RESTORE(x)
  33. #endif
  34. #endif // SOCI_PRIVATE_SOCI_COMPILER_H_INCLUDED