diff options
author | Daniel Elstner <daniel.kitta@gmail.com> | 2009-08-16 17:38:23 +0200 |
---|---|---|
committer | Daniel Elstner <daniel.kitta@gmail.com> | 2009-08-16 17:40:20 +0200 |
commit | 164df297d1b57f9fb1e717ca29c1944a964e85c6 (patch) | |
tree | a22602767cd2109308df2e0af6b87ee49b74dc33 | |
parent | f2a96e73398dc731c75bebb4b0f1287e33241224 (diff) | |
download | glibmm-164df297d1b57f9fb1e717ca29c1944a964e85c6.tar.gz |
Clean up C++ compiler test Autoconf macros
* build/cxx.m4: Clean up M4 code and switch to non-deprecated
Autoconf macros.
(AC_CXX_NAMESPACES), (AC_CXX_BOOL), (AC_CXX_MUTABLE): Remove
obsolete feature check macros.
* configure.ac: Remove AC_CXX_NAMESPACES(), AC_CXX_BOOL(),
AC_CXX_MUTABLE() and GLIBMM_CXX_HAS_NAMESPACE_STD checks.
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | build/cxx.m4 | 526 | ||||
-rw-r--r-- | configure.ac | 21 |
3 files changed, 218 insertions, 340 deletions
@@ -1,5 +1,16 @@ 2009-08-16 Daniel Elstner <daniel.kitta@gmail.com> + Clean up C++ compiler test Autoconf macros + + * build/cxx.m4: Clean up M4 code and switch to non-deprecated + Autoconf macros. + (AC_CXX_NAMESPACES), (AC_CXX_BOOL), (AC_CXX_MUTABLE): Remove + obsolete feature check macros. + * configure.ac: Remove AC_CXX_NAMESPACES(), AC_CXX_BOOL(), + AC_CXX_MUTABLE() and GLIBMM_CXX_HAS_NAMESPACE_STD checks. + +2009-08-16 Daniel Elstner <daniel.kitta@gmail.com> + Remove now optional macro arguments * configure.ac: Insert MM_PREREQ([0.4]) macro call. diff --git a/build/cxx.m4 b/build/cxx.m4 index 37062b75..a584f5db 100644 --- a/build/cxx.m4 +++ b/build/cxx.m4 @@ -1,360 +1,238 @@ +## Copyright (c) 2009 Openismus GmbH <http://www.openismus.com/> +## +## This file is part of glibmm. +## +## glibmm is free software: you can redistribute it and/or modify it +## under the terms of the GNU Lesser General Public License as published +## by the Free Software Foundation, either version 2.1 of the License, +## or (at your option) any later version. +## +## glibmm is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +## See the GNU Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public License +## along with this library. If not, see <http://www.gnu.org/licenses/>. -dnl -dnl AC_CXX_NAMESPACES(ACTION_FOUND,ACTION_NOT_FOUND) -dnl -AC_DEFUN([AC_CXX_NAMESPACES],[ -AC_MSG_CHECKING(if C++ compiler supports namespaces) -AC_TRY_COMPILE( -[ -namespace Foo { struct A {}; } -using namespace Foo; -],[ -A a; -(void)a; -],[ - ac_cxx_namespaces=yes - AC_MSG_RESULT([$ac_cxx_namespaces]) - $1 -],[ - ac_cxx_namespaces=no - AC_MSG_RESULT([$ac_cxx_namespaces]) - $2 -]) -]) +#serial 20090816 -dnl -dnl AC_CXX_NAMESPACES(ACTION_FOUND,ACTION_NOT_FOUND) -dnl -AC_DEFUN([AC_CXX_BOOL],[ -AC_MSG_CHECKING(if C++ compiler supports bool) -AC_TRY_COMPILE( -[ -],[ - bool b=true; - bool b1=false; - (void)b; - (void)b1; -],[ - ac_cxx_bool=yes - AC_MSG_RESULT([$ac_cxx_bool]) - $1 -],[ - ac_cxx_bool=no - AC_MSG_RESULT([$ac_cxx_bool]) - $2 -]) -]) - -dnl -dnl AC_CXX_MUTABLE(ACTION_FOUND,ACTION_NOT_FOUND) -dnl -AC_DEFUN([AC_CXX_MUTABLE],[ -AC_MSG_CHECKING(if C++ compiler supports mutable) -AC_TRY_COMPILE( -[ -class k { - mutable char *c; -public: - void foo() const { c=0; } +## GLIBMM_CXX_MEMBER_FUNCTIONS_MEMBER_TEMPLATES +## +## Test whether the compiler allows member functions to refer to spezialized +## member function templates. Some compilers have problems with this. GCC +## 2.95.3 aborts with an internal compiler error. +## +AC_DEFUN([GLIBMM_CXX_MEMBER_FUNCTIONS_MEMBER_TEMPLATES], +[dnl +AC_CACHE_CHECK( + [whether C++ member functions may refer to member templates], + [glibmm_cv_cxx_member_functions_member_templates], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM( +[[ +struct foo +{ + template <class C> inline void doit(); + void thebug(); }; -],[ -],[ - ac_cxx_mutable=yes - AC_MSG_RESULT([$ac_cxx_mutable]) - $1 -],[ - ac_cxx_mutable=no - AC_MSG_RESULT([$ac_cxx_mutable]) - $2 -]) -]) +template <class C> +inline void foo::doit() +{} -dnl -dnl AC_CXX_CONST_CAST(ACTION_FOUND,ACTION_NOT_FOUND) -dnl -AC_DEFUN([AC_CXX_CONST_CAST],[ -AC_MSG_CHECKING([if C++ compiler supports const_cast<>]) -AC_TRY_COMPILE( -[ - class foo; -],[ - const foo *c=0; - foo *c1=const_cast<foo*>(c); - (void)c1; -],[ - ac_cxx_const_cast=yes - AC_MSG_RESULT([$ac_cxx_const_cast]) -],[ - ac_cxx_const_cast=no - AC_MSG_RESULT([$ac_cxx_const_cast]) -]) -]) - - -dnl -dnl GLIBMM_CXX_MEMBER_FUNCTIONS_MEMBER_TEMPLATES(ACTION_FOUND,ACTION_NOT_FOUND) -dnl -dnl Test whether the compiler allows member functions to refer to spezialized member function templates. -dnl Some compilers have problems with this. gcc 2.95.3 aborts with an internal compiler error. -dnl -AC_DEFUN([GLIBMM_CXX_MEMBER_FUNCTIONS_MEMBER_TEMPLATES],[ -AC_MSG_CHECKING([if C++ compiler allows member functions to refer to member templates]) -AC_TRY_COMPILE( -[ - struct foo { - template <class C> inline - void doit(); - void thebug(); - }; - - template <class C> inline - void foo::doit() { - } - - struct bar { - void neitherabug(); - }; - - void notabug() { - void (foo::*func)(); - func = &foo::doit<int>; - (void)func; - } - - void bar::neitherabug() { - void (foo::*func)(); - func = &foo::doit<int>; - (void)func; - } +struct bar +{ + void neitherabug(); +}; - void foo::thebug() { - void (foo::*func)(); - func = &foo::doit<int>; //Compiler bugs usually show here. - (void)func; - } -],[],[glibmm_cxx_member_functions_member_templates=yes - AC_DEFINE([GLIBMM_MEMBER_FUNCTIONS_MEMBER_TEMPLATES], [1], - [does the C++ compiler allow member functions to refer to member templates]) -], [glibmm_cxx_member_functions_member_templates=no]) - AC_MSG_RESULT([$glibmm_cxx_member_functions_member_templates]) +void bar::neitherabug() +{ + void (foo::*func)(); + func = &foo::doit<int>; + (void)func; +} + +void foo::thebug() +{ + void (foo::*func)(); + func = &foo::doit<int>; // the compiler bugs usually show here + (void)func; +} +]], [[ +void (foo::*func)(); +func = &foo::doit<int>; +(void)func; +]], + [glibmm_cv_cxx_member_functions_member_templates=yes], + [glibmm_cv_cxx_member_functions_member_templates=no])])]) + +AS_IF([test "x$glibmm_cv_cxx_member_functions_member_templates" = xyes], + [AC_DEFINE([GLIBMM_MEMBER_FUNCTIONS_MEMBER_TEMPLATES], [1], + [Define if C++ member functions may refer to member templates.])])[]dnl ]) -## GLIBMM_CXX_CAN_DISAMBIGUATE_CONST_TEMPLATE_SPECIALIZATIONS() +## GLIBMM_CXX_CAN_DISAMBIGUATE_CONST_TEMPLATE_SPECIALIZATIONS ## -## Check whether the compiler finds it ambiguous to have both -## const and non-const template specializations, -## The SUN Forte compiler has this problem, though we are -## not 100% sure that it's a C++ standards violation. +## Check whether the compiler finds it ambiguous to have both const and +## non-const template specializations. The SUN Forte compiler has this +## problem, though we are not 100% sure that it's a C++ standard violation. ## AC_DEFUN([GLIBMM_CXX_CAN_DISAMBIGUATE_CONST_TEMPLATE_SPECIALIZATIONS], -[ - AC_REQUIRE([GLIBMM_CXX_HAS_NAMESPACE_STD]) - - AC_CACHE_CHECK( - [whether the compiler finds it ambiguous to have both const and non-const template specializations], - [glibmm_cv_cxx_can_disambiguate_const_template_specializations], - [ - AC_TRY_COMPILE( - [ - #include <iostream> - - template <class T> class Foo {}; - - template <typename T> class Traits { - public: - const char* whoami() { - return "generic template"; - } - }; - - template <typename T> class Traits<Foo<T> > { - public: - const char* whoami() { - return "partial specialization for Foo<T>"; - } - }; - - template <typename T> class Traits<Foo<const T> > { - public: - const char* whoami() { - return "partial specialization for Foo<const T>"; - } - }; - - ],[ - Traits<int> it; - Traits<Foo<int> > fit; - Traits<Foo<const int> > cfit; +[dnl +AC_CACHE_CHECK( + [whether the compiler disambiguates template specializations for const and non-const types], + [glibmm_cv_cxx_can_disambiguate_const_template_specializations], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM( +[[ +template <class T> class Foo {}; + +template <class T> class Traits +{ +public: + const char* whoami() { return "generic template"; } +}; - std::cout << "Traits<int> --> " - << it.whoami() << std::endl; - std::cout << "Traits<Foo<int>> --> " - << fit.whoami() << std::endl; - std::cout << "Traits<Foo<const int >> --> " - << cfit.whoami() << std::endl; - ], - [glibmm_cv_cxx_can_disambiguate_const_template_specializations="yes"], - [glibmm_cv_cxx_can_disambiguate_const_template_specializations="no"] - ) - ]) +template <class T> class Traits< Foo<T> > +{ +public: + const char* whoami() { return "partial specialization for Foo<T>"; } +}; - if test "x${glibmm_cv_cxx_can_disambiguate_const_template_specializations}" = "xyes"; then - { - AC_DEFINE([GLIBMM_HAVE_DISAMBIGUOUS_CONST_TEMPLATE_SPECIALIZATIONS],[1], [Defined if the compiler does not find it ambiguous to have both const and non-const template specializations]) - } - fi +template <class T> class Traits< Foo<const T> > +{ +public: + const char* whoami() { return "partial specialization for Foo<const T>"; } +}; +]], [[ +Traits<int> it; +Traits< Foo<int> > fit; +Traits< Foo<const int> > cfit; + +(void) it.whoami(); +(void) fit.whoami(); +(void) cfit.whoami(); +]], + [glibmm_cv_cxx_can_disambiguate_const_template_specializations=yes], + [glibmm_cv_cxx_can_disambiguate_const_template_specializations=no])])]) + +AS_IF([test "x$glibmm_cv_cxx_can_disambiguate_const_template_specializations" = xyes], + [AC_DEFINE([GLIBMM_HAVE_DISAMBIGUOUS_CONST_TEMPLATE_SPECIALIZATIONS], [1], +[Define if the compiler disambiguates template specializations for const and non-const types.])])[]dnl ]) - - -## GLIBMM_CXX_CAN_USE_DYNAMIC_CAST_IN_UNUSED_TEMPLATE_WITHOUT_DEFINITION() +## GLIBMM_CXX_CAN_USE_DYNAMIC_CAST_IN_UNUSED_TEMPLATE_WITHOUT_DEFINITION ## -## Check whether the compiler allows us to define a template that uses -## dynamic_cast<> with an object whose type is not defined, -## even if we do not use that template before we have defined the type. -## This should probably not be allowed anyway. +## Check whether the compiler allows us to define a template that uses +## dynamic_cast<> with an object whose type is not defined, even if we do +## not use that template before we have defined the type. This should +## probably not be allowed anyway. ## AC_DEFUN([GLIBMM_CXX_CAN_USE_DYNAMIC_CAST_IN_UNUSED_TEMPLATE_WITHOUT_DEFINITION], -[ - AC_CACHE_CHECK( - [whether the compiler allows us to define a template that uses dynamic_cast<> with an object whose type is not yet defined], - [glibmm_cv_cxx_can_use_dynamic_cast_in_unused_template_without_definition], - [ - AC_TRY_COMPILE( - [ - class SomeClass; - - SomeClass* some_function(); - - template <class T> - class SomeTemplate - { - static bool do_something() - { - //This does not compile, with the MipsPro (IRIX) compiler - //even if we don't use this template at all. - //(We would use it later, after we have defined the type). - return dynamic_cast<T*>(some_function()); - } - }; - - ],[ - - ], - [glibmm_cv_cxx_can_use_dynamic_cast_in_unused_template_without_definition="yes"], - [glibmm_cv_cxx_can_use_dynamic_cast_in_unused_template_without_definition="no"] - ) - ]) - - if test "x${glibmm_cv_cxx_can_use_dynamic_cast_in_unused_template_without_definition}" = "xyes"; then +[dnl +AC_CACHE_CHECK( + [whether the compiler allows dynamic_cast<> to undefined types in non-instantiated templates], + [glibmm_cv_cxx_can_use_dynamic_cast_in_unused_template_without_definition], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM( +[[ +class SomeClass; + +SomeClass* some_function(); + +template <class T> +class SomeTemplate +{ + static bool do_something() { - AC_DEFINE([GLIBMM_CAN_USE_DYNAMIC_CAST_IN_UNUSED_TEMPLATE_WITHOUT_DEFINITION],[1], [Defined if the compiler allows us to define a template that uses dynamic_cast<> with an object whose type is not yet defined.]) + // This does not compile with the MipsPro (IRIX) compiler + // even if we don't use this template at all. + return (dynamic_cast<T*>(some_function()) != 0); } - fi -]) +}; +]],, + [glibmm_cv_cxx_can_use_dynamic_cast_in_unused_template_without_definition=yes], + [glibmm_cv_cxx_can_use_dynamic_cast_in_unused_template_without_definition=no])])]) +AS_IF([test "x$glibmm_cv_cxx_can_use_dynamic_cast_in_unused_template_without_definition" = xyes], + [AC_DEFINE([GLIBMM_CAN_USE_DYNAMIC_CAST_IN_UNUSED_TEMPLATE_WITHOUT_DEFINITION], [1], + [Define if non-instantiated templates may dynamic_cast<> to an undefined type.])])[]dnl +]) -## GLIBMM_CXX_CAN_ASSIGN_NON_EXTERN_C_FUNCTIONS_TO_EXTERN_C_CALLBACKS() +## GLIBMM_CXX_CAN_ASSIGN_NON_EXTERN_C_FUNCTIONS_TO_EXTERN_C_CALLBACKS ## ## Check whether the compiler allows us to use a non-extern "C" function, ## such as a static member function, to an extern "C" function pointer, ## such as a GTK+ callback. -## This should not be allowed anyway. ## AC_DEFUN([GLIBMM_CXX_CAN_ASSIGN_NON_EXTERN_C_FUNCTIONS_TO_EXTERN_C_CALLBACKS], -[ - AC_CACHE_CHECK( - [whether the the compilerallows us to use a non-extern "C" function for an extern "C" function pointer.], - [glibmm_cv_cxx_can_assign_non_extern_c_functions_to_extern_c_callbacks], - [ - AC_TRY_COMPILE( - [ - extern "C" - { - struct somestruct - { - void (*callback) (int); - }; - - } // extern "C" - - void somefunction(int) - { - } - - ],[ - somestruct something; - something.callback = &somefunction; - ], - [glibmm_cv_cxx_can_assign_non_extern_c_functions_to_extern_c_callbacks="yes"], - [glibmm_cv_cxx_can_assign_non_extern_c_functions_to_extern_c_callbacks="no"] - ) - ]) - - if test "x${glibmm_cv_cxx_can_assign_non_extern_c_functions_to_extern_c_callbacks}" = "xyes"; then - { - AC_DEFINE([GLIBMM_CAN_ASSIGN_NON_EXTERN_C_FUNCTIONS_TO_EXTERN_C_CALLBACKS],[1], [Defined if the compiler allows us to use a non-extern "C" function for an extern "C" function pointer.]) - } - fi +[dnl +AC_CACHE_CHECK( + [whether extern "C" and extern "C++" function pointers are compatible], + [glibmm_cv_cxx_can_assign_non_extern_c_functions_to_extern_c_callbacks], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM( +[[ +extern "C" +{ +struct somestruct +{ + void (*callback) (int); +}; +} // extern "C" + +void somefunction(int) {} +]], [[ +somestruct something; +something.callback = &somefunction; +]], + [glibmm_cv_cxx_can_assign_non_extern_c_functions_to_extern_c_callbacks=yes], + [glibmm_cv_cxx_can_assign_non_extern_c_functions_to_extern_c_callbacks=no])])]) + +AS_IF([test "x$glibmm_cv_cxx_can_assign_non_extern_c_functions_to_extern_c_callbacks" = xyes], + [AC_DEFINE([GLIBMM_CAN_ASSIGN_NON_EXTERN_C_FUNCTIONS_TO_EXTERN_C_CALLBACKS], [1], + [Define if extern "C" and extern "C++" function pointers are compatible.])])[]dnl ]) -## GLIBMM_CXX_CAN_USE_NAMESPACES_INSIDE_EXTERNC() +## GLIBMM_CXX_CAN_USE_NAMESPACES_INSIDE_EXTERNC ## -## Check whether the compiler puts extern "C" functions in the global namespace, -## even inside a namespace declaration. The AIX xlC compiler does this, and also -## gets confused if we declare the namespace again inside the extern "C" block. -## This seems like a compiler bug, but not a serious one. +## Check whether the compiler puts extern "C" functions in the global +## namespace, even inside a namespace declaration. The AIX xlC compiler does +## this, and also gets confused if we declare the namespace again inside the +## extern "C" block. This seems like a compiler bug, but not a serious one. +## +## It is debatable whether it is a bug at all, since the namespace would only +## exist at the compiler level anyway, but not be a part of the exported +## symbol name. (For the functions in question, it was my fault not to add +## the namespace prefix to the function name. Sorry. --danielk) ## AC_DEFUN([GLIBMM_CXX_CAN_USE_NAMESPACES_INSIDE_EXTERNC], -[ - AC_CACHE_CHECK( - [whether the compiler uses namespace declarations inside extern "C" blocks.], - [glibmm_cv_cxx_can_use_namespaces_inside_externc], - [ - AC_TRY_COMPILE( - [ - namespace test - { - - extern "C" - { - - void do_something(); - - } //extern C - - - class Something - { - protected: - int i; - - friend void do_something(); - }; - - void do_something() - { - Something something; - something.i = 1; - } - - } //namespace +[dnl +AC_CACHE_CHECK( + [whether the compiler honors namespaces inside extern "C" blocks], + [glibmm_cv_cxx_can_use_namespaces_inside_externc], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM( +[[ +namespace test +{ + +extern "C" { void do_something(); } + +class Something +{ + int i; + friend void do_something(); +}; - - ],[ - - ], - [glibmm_cv_cxx_can_use_namespaces_inside_externc="yes"], - [glibmm_cv_cxx_can_use_namespaces_inside_externc="no"] - ) - ]) - - if test "x${glibmm_cv_cxx_can_use_namespaces_inside_externc}" = "xyes"; then - { - AC_DEFINE([GLIBMM_CAN_USE_NAMESPACES_INSIDE_EXTERNC],[1], [Defined if the compiler whether the compiler uses namespace declarations inside extern "C" blocks.]) - } - fi -]) +void do_something() +{ + Something something; + something.i = 1; +} +} // namespace test +]],, + [glibmm_cv_cxx_can_use_namespaces_inside_externc=yes], + [glibmm_cv_cxx_can_use_namespaces_inside_externc=no])])]) +AS_IF([test "x$glibmm_cv_cxx_can_use_namespaces_inside_externc" = xyes], + [AC_DEFINE([GLIBMM_CAN_USE_NAMESPACES_INSIDE_EXTERNC], [1], + [Define if the compiler honors namespaces inside extern "C" blocks.])])[]dnl +]) diff --git a/configure.ac b/configure.ac index afbcccdc..0a1315aa 100644 --- a/configure.ac +++ b/configure.ac @@ -46,14 +46,13 @@ AS_CASE([$host_os], [mingw*], [glibmm_host_windows=yes], [glibmm_host_windows=no AC_MSG_RESULT([$glibmm_host_windows]) AM_CONDITIONAL([HOST_WINDOWS_NATIVE], [test "x$glibmm_host_windows" = xyes]) +# TODO: This makes no sense. --danielk AS_IF([test "x$enable_static" = xyes], [ - AC_DEFINE([GLIBMM_STATIC_LIB], [1], [Defined when glibmm is built as a static library]) - AC_DEFINE([GIOMM_STATIC_LIB], [1], [Defined when giomm is built as a static library]) + AC_DEFINE([GLIBMM_STATIC_LIB], [1], [Define if glibmm is built as a static library]) + AC_DEFINE([GIOMM_STATIC_LIB], [1], [Define if giomm is built as a static library]) ]) -AC_CHECK_FUNCS([flockfile funlockfile getc_unlocked mkfifo]) - glibreq='2.0 >= 2.21.1' GLIBMM_MODULES="sigc++-2.0 >= 2.0 glib-$glibreq gobject-$glibreq gmodule-$glibreq" GIOMM_MODULES="$GLIBMM_MODULES gio-$glibreq" @@ -70,6 +69,8 @@ AC_CHECK_PROGS([M4], [gm4 m4], [m4]) # Check for the SUN Forte compiler, and define GLIBMM_COMPILER_SUN_FORTE in the header. GLIBMM_PROG_CXX_SUN +AC_CHECK_FUNCS([flockfile funlockfile getc_unlocked mkfifo]) + # Ensure MSVC-compatible struct packing convention is used when # compiling for Win32 with gcc. # TODO: Disabled for now. I don't think this should be enabled by the @@ -78,15 +79,6 @@ GLIBMM_PROG_CXX_SUN AC_LANG([C++]) -# TODO: I think we can just get rid of these checks. -glibmm_config_error=no -AC_CXX_BOOL(, [glibmm_config_error=yes]) -AC_CXX_NAMESPACES(, [glibmm_config_error=yes]) -AC_CXX_MUTABLE(, [glibmm_config_error=yes]) - -AS_IF([test "x$glibmm_config_error" = xyes], - [AC_MSG_FAILURE([[Your compiler is not powerful enough to compile glibmm.]])]) - AC_CHECK_SIZEOF([wchar_t]) DK_CHECK_FEATURE([wide stream], [ @@ -94,9 +86,6 @@ DK_CHECK_FEATURE([wide stream], [[std::wostringstream s; (void) s.str();]]) ]) -# TODO: This is completely pointless nowadays. -GLIBMM_CXX_HAS_NAMESPACE_STD - GLIBMM_CXX_HAS_STD_ITERATOR_TRAITS GLIBMM_CXX_HAS_SUN_REVERSE_ITERATOR GLIBMM_CXX_HAS_TEMPLATE_SEQUENCE_CTORS |