ac_cxx_compile_stdcxx_0x.m4 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. # ===========================================================================
  2. # http://autoconf-archive.cryp.to/ac_cxx_compile_stdcxx_0x.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AC_CXX_COMPILE_STDCXX_0X
  8. #
  9. # DESCRIPTION
  10. #
  11. # Check for baseline language coverage in the compiler for the C++0x
  12. # standard.
  13. #
  14. # LICENSE
  15. #
  16. # Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
  17. #
  18. # Copying and distribution of this file, with or without modification, are
  19. # permitted in any medium without royalty provided the copyright notice
  20. # and this notice are preserved.
  21. AC_DEFUN([AC_CXX_COMPILE_STDCXX_0X], [
  22. AC_CACHE_CHECK(if g++ supports C++0x features without additional flags,
  23. ac_cv_cxx_compile_cxx0x_native,
  24. [AC_LANG_SAVE
  25. AC_LANG_CPLUSPLUS
  26. AC_TRY_COMPILE([
  27. template <typename T>
  28. struct check
  29. {
  30. static_assert(sizeof(int) <= sizeof(T), "not big enough");
  31. };
  32. typedef check<check<bool>> right_angle_brackets;
  33. int a;
  34. decltype(a) b;
  35. typedef check<int> check_type;
  36. check_type c;
  37. check_type&& cr = c;],,
  38. ac_cv_cxx_compile_cxx0x_native=yes, ac_cv_cxx_compile_cxx0x_native=no)
  39. AC_LANG_RESTORE
  40. ])
  41. AC_CACHE_CHECK(if g++ supports C++0x features with -std=c++0x,
  42. ac_cv_cxx_compile_cxx0x_cxx,
  43. [AC_LANG_SAVE
  44. AC_LANG_CPLUSPLUS
  45. ac_save_CXXFLAGS="$CXXFLAGS"
  46. CXXFLAGS="$CXXFLAGS -std=c++0x"
  47. AC_TRY_COMPILE([
  48. template <typename T>
  49. struct check
  50. {
  51. static_assert(sizeof(int) <= sizeof(T), "not big enough");
  52. };
  53. typedef check<check<bool>> right_angle_brackets;
  54. int a;
  55. decltype(a) b;
  56. typedef check<int> check_type;
  57. check_type c;
  58. check_type&& cr = c;],,
  59. ac_cv_cxx_compile_cxx0x_cxx=yes, ac_cv_cxx_compile_cxx0x_cxx=no)
  60. CXXFLAGS="$ac_save_CXXFLAGS"
  61. AC_LANG_RESTORE
  62. ])
  63. AC_CACHE_CHECK(if g++ supports C++0x features with -std=gnu++0x,
  64. ac_cv_cxx_compile_cxx0x_gxx,
  65. [AC_LANG_SAVE
  66. AC_LANG_CPLUSPLUS
  67. ac_save_CXXFLAGS="$CXXFLAGS"
  68. CXXFLAGS="$CXXFLAGS -std=gnu++0x"
  69. AC_TRY_COMPILE([
  70. template <typename T>
  71. struct check
  72. {
  73. static_assert(sizeof(int) <= sizeof(T), "not big enough");
  74. };
  75. typedef check<check<bool>> right_angle_brackets;
  76. int a;
  77. decltype(a) b;
  78. typedef check<int> check_type;
  79. check_type c;
  80. check_type&& cr = c;],,
  81. ac_cv_cxx_compile_cxx0x_gxx=yes, ac_cv_cxx_compile_cxx0x_gxx=no)
  82. CXXFLAGS="$ac_save_CXXFLAGS"
  83. AC_LANG_RESTORE
  84. ])
  85. if test "$ac_cv_cxx_compile_cxx0x_native" = yes ||
  86. test "$ac_cv_cxx_compile_cxx0x_cxx" = yes ||
  87. test "$ac_cv_cxx_compile_cxx0x_gxx" = yes; then
  88. AC_DEFINE(HAVE_STDCXX_0X,,[Define if g++ supports C++0x features. ])
  89. fi
  90. ])