Hi Gary, Bob, * Gary V. Vaughan wrote on Sat, Sep 10, 2005 at 05:04:45PM CEST: > Ralf Wildenhues wrote: > > I'd like this question clarified before I start > > reimplementing: > > > > * Ralf Wildenhues wrote on Thu, Sep 08, 2005 at 06:25:14PM CEST: > > > >>What should we do with the C++ tests in the new-style test suite? > >>(ordered in my decreasing order of my personal preference) > >>- remove use of iostream *snip*
> >>If nobody objects, I'll do the first. > > The first seems perfectly reasonable. Please go right ahead! I have applied this patch to HEAD, after testing it on Solaris. :) tagdemo has a straightforward reimplementation of the tests now. Thanks guys, Ralf 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. Index: tests/am-subdir.at =================================================================== RCS file: /cvsroot/libtool/libtool/tests/am-subdir.at,v retrieving revision 1.5 diff -u -r1.5 am-subdir.at --- tests/am-subdir.at 27 Apr 2005 18:18:10 -0000 1.5 +++ tests/am-subdir.at 12 Sep 2005 15:44:29 -0000 @@ -129,37 +129,27 @@ 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 <iostream.h> -#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 <iostream.h> -#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 Index: tests/template.at =================================================================== RCS file: /cvsroot/libtool/libtool/tests/template.at,v retrieving revision 1.7 diff -u -r1.7 template.at --- tests/template.at 26 Aug 2005 13:48:27 -0000 1.7 +++ tests/template.at 12 Sep 2005 15:44:29 -0000 @@ -62,18 +62,12 @@ ]]) AT_DATA(prog.cpp, -[[#include <iostream> -#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; } ]]) Index: tests/tagdemo/configure.ac =================================================================== RCS file: /cvsroot/libtool/libtool/tests/tagdemo/configure.ac,v retrieving revision 1.12 diff -u -r1.12 configure.ac --- tests/tagdemo/configure.ac 23 Aug 2005 01:49:37 -0000 1.12 +++ tests/tagdemo/configure.ac 12 Sep 2005 15:44:29 -0000 @@ -45,6 +45,30 @@ 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 <iostream> +#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 Index: tests/tagdemo/foo.cpp =================================================================== RCS file: /cvsroot/libtool/libtool/tests/tagdemo/foo.cpp,v retrieving revision 1.2 diff -u -r1.2 foo.cpp --- tests/tagdemo/foo.cpp 22 Apr 2005 10:10:31 -0000 1.2 +++ tests/tagdemo/foo.cpp 12 Sep 2005 15:44:29 -0000 @@ -20,7 +20,14 @@ // USA. #include "foo.h" -#include <iostream.h> +#ifdef HAVE_IOSTREAM +# include <iostream> +#else +# include <iostream.h> +#endif +#ifdef HAVE_NAMESPACES +using namespace std; +#endif #ifdef HAVE_MATH_H #include <math.h> Index: tests/tagdemo/main.cpp =================================================================== RCS file: /cvsroot/libtool/libtool/tests/tagdemo/main.cpp,v retrieving revision 1.3 diff -u -r1.3 main.cpp --- tests/tagdemo/main.cpp 22 Apr 2005 10:10:31 -0000 1.3 +++ tests/tagdemo/main.cpp 12 Sep 2005 15:44:29 -0000 @@ -23,7 +23,14 @@ #include "foo.h" #include "baz.h" #include "conv.h" -#include <iostream.h> +#ifdef HAVE_IOSTREAM +# include <iostream> +#else +# include <iostream.h> +#endif +#ifdef HAVE_NAMESPACES +using namespace std; +#endif int