ax_cxx_compile_stdcxx_0x.m4 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. #serial 5
  22. AC_DEFUN([AC_CXX_COMPILE_STDCXX_0X], [
  23. AC_CACHE_CHECK(if g++ supports C++0x features without additional flags,
  24. ac_cv_cxx_compile_cxx0x_native,
  25. [AC_LANG_SAVE
  26. AC_LANG_C
  27. AC_TRY_COMPILE([
  28. template <typename T>
  29. struct check
  30. {
  31. static_assert(sizeof(int) <= sizeof(T), "not big enough");
  32. };
  33. typedef check<check<bool>> right_angle_brackets;
  34. int a;
  35. decltype(a) b;
  36. typedef check<int> check_type;
  37. check_type c;
  38. check_type&& cr = c;],,
  39. ac_cv_cxx_compile_cxx0x_native=yes, ac_cv_cxx_compile_cxx0x_native=no)
  40. AC_LANG_RESTORE
  41. ])
  42. AC_CACHE_CHECK(if g++ supports C++0x features with -std=c++0x,
  43. ac_cv_cxx_compile_cxx0x_cxx,
  44. [AC_LANG_SAVE
  45. AC_LANG_CPLUSPLUS
  46. ac_save_CXXFLAGS="$CXXFLAGS"
  47. CXXFLAGS="$CXXFLAGS -std=c++0x"
  48. AC_TRY_COMPILE([
  49. template <typename T>
  50. struct check
  51. {
  52. static_assert(sizeof(int) <= sizeof(T), "not big enough");
  53. };
  54. typedef check<check<bool>> right_angle_brackets;
  55. int a;
  56. decltype(a) b;
  57. typedef check<int> check_type;
  58. check_type c;
  59. check_type&& cr = c;],,
  60. ac_cv_cxx_compile_cxx0x_cxx=yes, ac_cv_cxx_compile_cxx0x_cxx=no)
  61. CXXFLAGS="$ac_save_CXXFLAGS"
  62. AC_LANG_RESTORE
  63. ])
  64. AC_CACHE_CHECK(if g++ supports C++0x features with -std=gnu++0x,
  65. ac_cv_cxx_compile_cxx0x_gxx,
  66. [AC_LANG_SAVE
  67. AC_LANG_CPLUSPLUS
  68. ac_save_CXXFLAGS="$CXXFLAGS"
  69. CXXFLAGS="$CXXFLAGS -std=gnu++0x"
  70. AC_TRY_COMPILE([
  71. template <typename T>
  72. struct check
  73. {
  74. static_assert(sizeof(int) <= sizeof(T), "not big enough");
  75. };
  76. typedef check<check<bool>> right_angle_brackets;
  77. int a;
  78. decltype(a) b;
  79. typedef check<int> check_type;
  80. check_type c;
  81. check_type&& cr = c;],,
  82. ac_cv_cxx_compile_cxx0x_gxx=yes, ac_cv_cxx_compile_cxx0x_gxx=no)
  83. CXXFLAGS="$ac_save_CXXFLAGS"
  84. AC_LANG_RESTORE
  85. ])
  86. if test "$ac_cv_cxx_compile_cxx0x_native" = yes ||
  87. test "$ac_cv_cxx_compile_cxx0x_cxx" = yes ||
  88. test "$ac_cv_cxx_compile_cxx0x_gxx" = yes; then
  89. AC_DEFINE(HAVE_STDCXX_0X,,[Define if g++ supports C++0x features. ])
  90. fi
  91. ])