]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
Make tagdemo work smoothly with both pre- and ISO C++ compilers,
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Mon, 12 Sep 2005 16:24:38 +0000 (16:24 +0000)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Mon, 12 Sep 2005 16:24:38 +0000 (16:24 +0000)
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.

ChangeLog
tests/am-subdir.at
tests/tagdemo/configure.ac
tests/tagdemo/foo.cpp
tests/tagdemo/main.cpp
tests/template.at

index 2bc3a57338fac5fed15620e8b0312465554bd93c..5402649639a8504f915814e67db690ecf45a93e5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2005-09-12  Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
+
+       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  <peda@axentia.se>,
            Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
 
index 8c90627281b07c86178c60b0df8c5a514e9e1aa8..2258121bd1be0c5e874788b2184741cf5a1703ee 100644 (file)
@@ -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 <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 f58f112ad6369fd038b3d05292b9b12dd5dfcb72..a3a46c7f78015443eb3ea0ec2e852af28a039a98 100644 (file)
@@ -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 <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 2867ed9683bb4eec37561e7fb070b0c55c844b79..d3428116a060bbaf48aa0f319071a4c637f5ab32 100644 (file)
 // 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 a84f6316df4beaaf110982b29cc7dc8a416d1f79..32ed0cadf99ab715bdb8e1ae73cf1cd18fddc03e 100644 (file)
 #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
index a96d62ae4e1ac98b0132c1cb95b9ae89a4ce61fe..3ba33b25a5c70f34822ec6962eaab760f4250742 100644 (file)
@@ -62,18 +62,12 @@ int f(int i)
 ]])
 
 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;
 }
 ]])