diff --git a/ChangeLog b/ChangeLog index 2bc3a573..54026496 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 8c906272..2258121b 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" +[[#include "sub.hxx" -void libsub::sub (void) { cout << "** This is libsub::sub **" << endl; } -]]) - -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 f58f112a..a3a46c7f 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 2867ed96..d3428116 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 a84f6316..32ed0cad 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 a96d62ae..3ba33b25 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; } ]])