[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
HEAD: make tagdemo use new-style headers and namespaces if possible
From: |
Ralf Wildenhues |
Subject: |
HEAD: make tagdemo use new-style headers and namespaces if possible |
Date: |
Thu, 8 Sep 2005 18:25:14 +0200 |
User-agent: |
Mutt/1.4.1i |
Beating a hopefully dying horse:
This patch should make tagdemo pass with all sorts of (non-)conforming
C++ compilers. AC_CXX_NAMESPACES and AC_CXX_HAVE_STD are taken from the
autoconf macro archive. A macro to put all compilers in ISO C++ mode
would've been nicer, but a quick search hasn't turned up one.
OK for CVS HEAD?
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
- do nothing and wait for bug reports to show up
- use these tests there as well (at least in am-subdir.at).
If nobody objects, I'll do the first.
As a side-issue, this should make the tests work with MSVC.
Cheers,
Ralf
Make tagdemo work smoothly with both pre- and ISO C++ compilers.
* tests/tagdemo/m4: New directory.
* tests/tagdemo/m4/ac_cxx_have_std.m4,
tests/tagdemo/m4/ac_cxx_namespaces.m4: New, from the autoconf
macro archive.
* tests/tagdemo/Makefile.am, tests/tagdemo/configure.ac,
tests/tagdemo/foo.cpp, tests/tagdemo/main.cpp: Adjusted.
Index: tests/tagdemo/Makefile.am
===================================================================
RCS file: /cvsroot/libtool/libtool/tests/tagdemo/Makefile.am,v
retrieving revision 1.8
diff -u -r1.8 Makefile.am
--- tests/tagdemo/Makefile.am 23 Aug 2005 01:49:37 -0000 1.8
+++ tests/tagdemo/Makefile.am 8 Sep 2005 18:52:45 -0000
@@ -18,7 +18,7 @@
## Boston, MA 02110-1301, USA.
AUTOMAKE_OPTIONS = no-dependencies foreign
-ACLOCAL_AMFLAGS = -I ../../libltdl/m4
+ACLOCAL_AMFLAGS = -I ../../libltdl/m4 -I m4
AM_CPPFLAGS = -I$(top_srcdir)/../..
noinst_LTLIBRARIES = libconv.la
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 8 Sep 2005 18:52:45 -0000
@@ -45,6 +45,11 @@
AC_PROG_CXX
AC_PROG_CXXCPP
+dnl Check for namespace support and new-style headers
+dnl macros taken from the autoconf macro archive
+AC_CXX_NAMESPACES
+AC_CXX_HAVE_STD
+
# 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 8 Sep 2005 18:52:45 -0000
@@ -20,7 +20,14 @@
// USA.
#include "foo.h"
-#include <iostream.h>
+#ifdef HAVE_STD
+# 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 8 Sep 2005 18:52:45 -0000
@@ -23,7 +23,14 @@
#include "foo.h"
#include "baz.h"
#include "conv.h"
-#include <iostream.h>
+#ifdef HAVE_STD
+# include <iostream>
+#else
+# include <iostream.h>
+#endif
+#ifdef HAVE_NAMESPACES
+using namespace std;
+#endif
int
--- /dev/null 2005-08-03 12:45:51.659987528 +0200
+++ tests/tagdemo/m4/ac_cxx_have_std.m4 2005-09-08 18:47:35.000000000 +0200
@@ -0,0 +1,28 @@
+dnl @synopsis AC_CXX_HAVE_STD
+dnl
+dnl If the compiler supports ISO C++ standard library (i.e., can include the
+dnl files iostream, map, iomanip and cmath}), define HAVE_STD.
+dnl
+dnl @version $Id: ac_cxx_have_std.m4,v 1.2 2004/02/15 10:08:19 guidod Exp $
+dnl @author Todd Veldhuizen and Luc Maisonobe <address@hidden>
+dnl
+AC_DEFUN([AC_CXX_HAVE_STD],
+[AC_CACHE_CHECK(whether the compiler supports ISO C++ standard library,
+ac_cv_cxx_have_std,
+[AC_REQUIRE([AC_CXX_NAMESPACES])
+ AC_LANG_SAVE
+ AC_LANG_CPLUSPLUS
+ AC_TRY_COMPILE([#include <iostream>
+#include <map>
+#include <iomanip>
+#include <cmath>
+#ifdef HAVE_NAMESPACES
+using namespace std;
+#endif],[return 0;],
+ ac_cv_cxx_have_std=yes, ac_cv_cxx_have_std=no)
+ AC_LANG_RESTORE
+])
+if test "$ac_cv_cxx_have_std" = yes; then
+ AC_DEFINE(HAVE_STD,,[define if the compiler supports ISO C++ standard
library])
+fi
+])
--- /dev/null 2005-08-03 12:45:51.659987528 +0200
+++ tests/tagdemo/m4/ac_cxx_namespaces.m4 2005-09-08 18:47:44.000000000
+0200
@@ -0,0 +1,22 @@
+dnl @synopsis AC_CXX_NAMESPACES
+dnl
+dnl If the compiler can prevent names clashes using namespaces, define
+dnl HAVE_NAMESPACES.
+dnl
+dnl @version $Id: ac_cxx_namespaces.m4,v 1.2 2004/02/15 10:06:27 guidod Exp $
+dnl @author Todd Veldhuizen and Luc Maisonobe <address@hidden>
+dnl
+AC_DEFUN([AC_CXX_NAMESPACES],
+[AC_CACHE_CHECK(whether the compiler implements namespaces,
+ac_cv_cxx_namespaces,
+[AC_LANG_SAVE
+ AC_LANG_CPLUSPLUS
+ AC_TRY_COMPILE([namespace Outer { namespace Inner { int i = 0; }}],
+ [using namespace Outer::Inner; return i;],
+ ac_cv_cxx_namespaces=yes, ac_cv_cxx_namespaces=no)
+ AC_LANG_RESTORE
+])
+if test "$ac_cv_cxx_namespaces" = yes; then
+ AC_DEFINE(HAVE_NAMESPACES,,[define if the compiler implements namespaces])
+fi
+])
- HEAD: make tagdemo use new-style headers and namespaces if possible,
Ralf Wildenhues <=
- Re: HEAD: make tagdemo use new-style headers and namespaces if possible, Bob Friesenhahn, 2005/09/08
- Re: HEAD: make tagdemo use new-style headers and namespaces if possible, Ralf Wildenhues, 2005/09/08
- Re: HEAD: make tagdemo use new-style headers and namespaces if possible, Bob Friesenhahn, 2005/09/08
- Re: HEAD: make tagdemo use new-style headers and namespaces if possible, Bob Friesenhahn, 2005/09/08
- Re: HEAD: make tagdemo use new-style headers and namespaces if possible, Ralf Wildenhues, 2005/09/08
- Re: HEAD: make tagdemo use new-style headers and namespaces if possible, Gary V. Vaughan, 2005/09/10
- Re: HEAD: make tagdemo use new-style headers and namespaces if possible, Ralf Wildenhues, 2005/09/12