From: Ralf Wildenhues Date: Mon, 12 Sep 2005 16:24:38 +0000 (+0000) Subject: Make tagdemo work smoothly with both pre- and ISO C++ compilers, X-Git-Tag: release-2-1b~518 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2055f11ca7015f0032cef8ecf1bf054ce8c1c74d;p=thirdparty%2Flibtool.git Make tagdemo work smoothly with both pre- and ISO C++ compilers, and remove all use of libstdc from other tests. * tests/tagdemo/configure.ac (HAVE_NAMESPACES, HAVE_IOSTREAM): New tests for ISO C++ features. Reimplementation of similar macros from the autoconf archive. * tests/tagdemo/foo.cpp, tests/tagdemo/main.cpp: Adjusted. * tests/am-subdir.at, tests/template.at: Do not use iostream. --- diff --git a/ChangeLog b/ChangeLog index 2bc3a5733..540264963 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2005-09-12 Ralf Wildenhues + + Make tagdemo work smoothly with both pre- and ISO C++ compilers, + and remove all use of libstdc from other tests. + + * tests/tagdemo/configure.ac (HAVE_NAMESPACES, HAVE_IOSTREAM): + New tests for ISO C++ features. Reimplementation of similar + macros from the autoconf archive. + * tests/tagdemo/foo.cpp, tests/tagdemo/main.cpp: Adjusted. + * tests/am-subdir.at, tests/template.at: Do not use iostream. + 2005-09-12 Peter Ekberg , Ralf Wildenhues diff --git a/tests/am-subdir.at b/tests/am-subdir.at index 8c9062728..2258121bd 100644 --- a/tests/am-subdir.at +++ b/tests/am-subdir.at @@ -129,37 +129,27 @@ subdir_subdemo_LDADD = subdir/libsub.la test -d subdir || { rm -f subdir && mkdir subdir; } AT_DATA([[subdir/sub.hxx]], -[[class libsub { public: void sub (void); }; +[[class libsub { public: int sub (void); }; ]]) AT_DATA([[subdir/main.cxx]], -[[#include -#include "sub.hxx" +[[#include "sub.hxx" int main (int, char *[]) { libsub SUB; - - cout << "Welcome to GNU Libtool subdir-objects C++ test!" << endl; - SUB.sub(); - return 0; + return SUB.sub() != 27; } ]]) AT_DATA([[subdir/sub.cxx]], -[[#include -#include "sub.hxx" - -void libsub::sub (void) { cout << "** This is libsub::sub **" << endl; } -]]) +[[#include "sub.hxx" -AT_DATA(expout, -[[Welcome to GNU Libtool subdir-objects C++ test! -** This is libsub::sub ** +int libsub::sub (void) { return 27; } ]]) LT_AT_BOOTSTRAP "${MAKE-make}" -LT_AT_EXEC_CHECK([subdir/subdemo], 0, expout) +LT_AT_EXEC_CHECK([subdir/subdemo], 0) AT_CLEANUP diff --git a/tests/tagdemo/configure.ac b/tests/tagdemo/configure.ac index f58f112ad..a3a46c7f7 100644 --- a/tests/tagdemo/configure.ac +++ b/tests/tagdemo/configure.ac @@ -45,6 +45,30 @@ AC_PROG_CC_C_O AC_PROG_CXX AC_PROG_CXXCPP +# Check for namespace support and new-style headers +AC_LANG_PUSH([C++]) +AC_MSG_CHECKING([whether the compiler implements namespaces]) +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[namespace A { namespace B { int i = 0; }}]], + [[using namespace A::B; return i;]])], + [AC_MSG_RESULT([yes]) + AC_DEFINE([HAVE_NAMESPACES],[1], + [define if the compiler implements namespaces])], + [AC_MSG_RESULT([no])]) + +AC_MSG_CHECKING([whether the compiler has ISO C++ iostream]) +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#include +#ifdef HAVE_NAMESPACES +using namespace std; +#endif ]], [[cout << "bingo\n"; return 0;]])], + [AC_MSG_RESULT([yes]) + AC_DEFINE([HAVE_IOSTREAM],[1], + [define if the compiler has ISO C++ iostream])], + [AC_MSG_RESULT([no])]) +AC_LANG_POP([C++]) + + # As of the writing of this demo, GNU Autoconf's AC_OBJEXT and # AC_EXEEXT macros only works for C compilers! # Libtool's setup macro calls AC_OBJEXT and AC_EXEEXT without setting diff --git a/tests/tagdemo/foo.cpp b/tests/tagdemo/foo.cpp index 2867ed968..d3428116a 100644 --- a/tests/tagdemo/foo.cpp +++ b/tests/tagdemo/foo.cpp @@ -20,7 +20,14 @@ // USA. #include "foo.h" -#include +#ifdef HAVE_IOSTREAM +# include +#else +# include +#endif +#ifdef HAVE_NAMESPACES +using namespace std; +#endif #ifdef HAVE_MATH_H #include diff --git a/tests/tagdemo/main.cpp b/tests/tagdemo/main.cpp index a84f6316d..32ed0cadf 100644 --- a/tests/tagdemo/main.cpp +++ b/tests/tagdemo/main.cpp @@ -23,7 +23,14 @@ #include "foo.h" #include "baz.h" #include "conv.h" -#include +#ifdef HAVE_IOSTREAM +# include +#else +# include +#endif +#ifdef HAVE_NAMESPACES +using namespace std; +#endif int diff --git a/tests/template.at b/tests/template.at index a96d62ae4..3ba33b25a 100644 --- a/tests/template.at +++ b/tests/template.at @@ -62,18 +62,12 @@ int f(int i) ]]) AT_DATA(prog.cpp, -[[#include -#include "alib.h" +[[#include "alib.h" #include "aclib.h" -using namespace std; - int main() { - cout << "a sample prog" << endl; - cout << "f(3) = " << f(3) << endl; - cout << "cf(3) = " << cf(3) << endl; - return (f(3) + 3 - cf(3) != 0); + return f(3) + 3 - cf(3) != 0; } ]])