📄 cxx.m4
字号:
dnl ######################################################################dnldnl Determine C++ compiler characteristicsdnldnl ######################################################################dnl ######################################################################dnldnl Check whether c++ compiler supports exception handlingdnldnl ######################################################################AC_CACHE_CHECK(whether c++ compiler supports exception handling,ac_cv_exception_handling,AC_LANG_SAVEAC_LANG_CPLUSPLUSAC_TRY_COMPILE_GLOBAL(,void f() { throw "abc"; }void g() { try { f(); } catch(char*) { } },ac_cv_exception_handling=yes, ac_cv_exception_handling=no)AC_LANG_RESTORE)if test $ac_cv_exception_handling = nothen AC_MSG_WARN(Compiler does not support exception handling!)fidnl ######################################################################dnldnl Check whether c++ compiler supports typenamednldnl ######################################################################AC_CACHE_CHECK(whether c++ compiler supports typename,ac_cv_typename,AC_LANG_SAVEAC_LANG_CPLUSPLUSAC_TRY_COMPILE_GLOBAL(,template<class T> class X { typedef typename T::Y Y; };class Z { public: typedef int Y; };X<Z> x;,ac_cv_typename=yes, ac_cv_typename=no)AC_LANG_RESTORE)if test $ac_cv_typename = nothen AC_MSG_WARN(Compiler does not support typename!)fidnl ######################################################################dnldnl Check whether c++ compiler can explicitly instantiate templatesdnldnl ######################################################################AC_CACHE_CHECK(whether c++ compiler can explicitly instantiate templates,ac_cv_explicit_templates,AC_LANG_SAVEAC_LANG_CPLUSPLUSAC_TRY_COMPILE_GLOBAL(,template<class T> class X { T t; }; template class X<int>; X<int> x;,ac_cv_explicit_templates=yes, ac_cv_explicit_templates=no)AC_LANG_RESTORE)if test $ac_cv_explicit_templates = nothen AC_MSG_WARN(Compiler does not support explicit instantiation of templates!)fidnl ######################################################################dnldnl Check whether c++ compiler supports RTTIdnldnl ######################################################################AC_CACHE_CHECK(whether c++ compiler supports RTTI,ac_cv_rtti,AC_LANG_SAVEAC_LANG_CPLUSPLUSAC_TRY_COMPILE_GLOBAL(,struct X { virtual ~X() { } };struct Y : virtual public X { virtual ~Y() { } };void f() { Y y; X* xp = &y; Y* yp = dynamic_cast<Y*>(xp); },ac_cv_rtti=yes, ac_cv_rtti=no)AC_LANG_RESTORE)if test $ac_cv_rtti = nothen AC_DEFINE(HAVE_NO_RTTI)fidnl ######################################################################dnldnl Check whether c++ compiler supports namespacesdnldnl ######################################################################AC_CACHE_CHECK(whether c++ compiler supports namespaces,ac_cv_namespaces,AC_LANG_SAVEAC_LANG_CPLUSPLUSAC_TRY_COMPILE_GLOBAL(,namespace N { typedef int I; }; N::I i;,ac_cv_namespaces=yes, ac_cv_namespaces=no)AC_LANG_RESTORE)if test $ac_cv_namespaces = yesthen AC_DEFINE(HAVE_NAMESPACES)fidnl ######################################################################dnldnl Check whether c++ compiler has complex in the namespace stddnldnl ######################################################################if test $ac_cv_namespaces = yesthen AC_CACHE_CHECK(whether c++ compiler has complex in the namespace std, ac_cv_std_complex, AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE_GLOBAL( , #include <complex> std::complex<double> cd; , ac_cv_std_complex=yes, ac_cv_std_complex=no) AC_LANG_RESTORE) if test $ac_cv_std_complex = yes then AC_DEFINE(HAVE_STD_COMPLEX) fifidnl ######################################################################dnldnl Check whether c++ compiler has streams in the namespace stddnldnl ######################################################################if test $ac_cv_namespaces = yesthen AC_CACHE_CHECK(whether c++ compiler has streams in the namespace std, ac_cv_std_streams, AC_LANG_SAVE AC_LANG_CPLUSPLUS # if test $ac_cv_header_iostream = yes # then AC_TRY_COMPILE_GLOBAL( , #include <iostream> using namespace std; , ac_cv_std_streams=yes, ac_cv_std_streams=no) # else # AC_TRY_COMPILE_GLOBAL( # , # #include <iostream.h> # using namespace std; # , # ac_cv_std_streams=yes, ac_cv_std_streams=no) # fi AC_LANG_RESTORE) if test $ac_cv_std_streams = yes then AC_DEFINE(HAVE_STD_STREAMS) fifidnl ######################################################################dnldnl Check whether c++ compiler uses sstream instead of strstreamdnldnl ######################################################################dnl if test $ac_cv_namespaces = yesdnl thendnl AC_CACHE_CHECK(whether c++ compiler uses sstream instead of strstream,dnl ac_cv_sstream,dnl AC_LANG_SAVEdnl AC_LANG_CPLUSPLUSdnl AC_TRY_COMPILE_GLOBAL(dnl ,dnl #include <sstream>dnl ,dnl ac_cv_sstream=yes, ac_cv_sstream=no)dnl AC_LANG_RESTORE)dnl dnl if test $ac_cv_sstream = yesdnl thendnl AC_DEFINE(HAVE_SSTREAM)dnl fidnl fidnl ######################################################################dnldnl Check whether c++ compiler can overload const type conversionsdnldnl ######################################################################AC_CACHE_CHECK(whether c++ compiler can overload const type conversions,ac_cv_const_type_conversion_overload,AC_LANG_SAVEAC_LANG_CPLUSPLUSAC_TRY_COMPILE_GLOBAL(,struct X { int* p_; X(int* p) : p_(p) { }operator int&() { return *p_; } operator const int&() const { return *p_; }operator int*() { return p_; } operator const int*() const { return p_; } };void f() { int i = 1; int j = 2;X x(&i); const X cx(&j); int k = x; int l = cx; k = *x; l = *cx; },ac_cv_const_type_conversion_overload=yes,ac_cv_const_type_conversion_overload=no)if test $ac_cv_const_type_conversion_overload = yesthen AC_TRY_COMPILE_GLOBAL( , struct X { int* p_; X(int* p) : p_(p) { } operator int&() { return *p_; } operator int() const { return *p_; } }; void f() { int i = 1; int j = 2; X x(&i); const X cx(&j); int k = x; int l = cx; } , ac_cv_const_type_conversion_overload=yes, ac_cv_const_type_conversion_overload=no)fiAC_LANG_RESTORE)if test $ac_cv_const_type_conversion_overload = nothen AC_DEFINE(HAVE_NO_CONST_TYPE_CONVERSION_OVERLOAD)fidnl ######################################################################dnldnl Check whether c++ compiler knows mutablednldnl ######################################################################AC_CACHE_CHECK(whether c++ compiler knows mutable,ac_cv_mutable,AC_LANG_SAVEAC_LANG_CPLUSPLUSAC_TRY_COMPILE_GLOBAL(,class X { mutable int i; }; X x;,ac_cv_mutable=yes, ac_cv_mutable=no)AC_LANG_RESTORE)if test $ac_cv_mutable = nothen AC_DEFINE(HAVE_NO_MUTABLE)fidnl ######################################################################dnldnl Check whether template friends need bracketsdnldnl ######################################################################AC_CACHE_CHECK(whether template friends need brackets,ac_cv_template_friends_need_brackets,AC_LANG_SAVEAC_LANG_CPLUSPLUSAC_TRY_COMPILE_GLOBAL(,template <class T2> int foo(T2 t2);template <class T1> class X { T1 t; friend int foo<> (T1); };X<double> x;,ac_cv_template_friends_need_brackets=yes, ac_cv_template_friends_need_brackets=no)AC_LANG_RESTORE)if test $ac_cv_template_friends_need_brackets = yesthen AC_DEFINE(TEMPLATE_FRIENDS_NEED_BRACKETS)fidnl ######################################################################dnldnl Check whether template friend operators allowed. Works only for ansidnl declaration with <>.dnldnl ######################################################################AC_CACHE_CHECK(whether nontype template operators are allowed,ac_cv_nontype_template_operators,AC_LANG_SAVEAC_LANG_CPLUSPLUSAC_TRY_COMPILE_GLOBAL(,template <int d> class X { friend void operator<< <> (int, X<d>&); };template <int d> void operator<< (int i, X<d>& xx){}X<1> x;,ac_cv_nontype_template_operators=yes, ac_cv_nontype_template_operators=no)AC_LANG_RESTORE)if test $ac_cv_nontype_template_operators = yesthen AC_DEFINE(HAVE_NONTYPE_TEMPLATE_OPERATORS)fi
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -