On Thu, Oct 11, 2001 at 10:16:38AM +0400, Alexander V. Lukyanov wrote:
> > Asked someone in debian/potato to try this out; the static initializer
> > test failed.
> > 
> > Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.2/specs
> > gcc version 2.95.2 20000220 (Debian GNU/Linux)
> 
> This usually means that gcc was incorrecly compiled itself. The feature is

In this case, he had gcc installed, but not g++; for some reason, this
installs a "g++" binary (that fails) in Debian.

Attached is a patch to test C++ compiler sanity early, so failure doesn't
come up with some irrelevant error message later and confuse innocent
programmers. :)

> int f() { return 1; }
> static int a=f();

By the way, the test reads:

int f() { return 1; }
int a=f();
  
not static.  It probably doesn't matter.  (There are issues with non-static
global initializers across source files, of course, but that's not what's
being tested here.)

-- 
Glenn Maynard
Index: configure.in
===================================================================
RCS file: /home/lav/cvsroot/lftp/configure.in,v
retrieving revision 1.105
diff -u -r1.105 configure.in
--- configure.in        2001/09/13 15:37:33     1.105
+++ configure.in        2001/10/11 07:29:28
@@ -20,6 +20,9 @@
 AC_PROG_CC
 AC_PROG_CXX
 
+dnl Make sure C++ build environment is sane.
+LFTP_CXX_TEST
+
 dnl AC_CANONICAL_HOST
 AC_ISC_POSIX
 
Index: m4/lftp.m4
===================================================================
RCS file: /home/lav/cvsroot/lftp/m4/lftp.m4,v
retrieving revision 1.1
diff -u -r1.1 lftp.m4
--- m4/lftp.m4  2001/03/22 12:46:51     1.1
+++ m4/lftp.m4  2001/10/11 07:29:28
@@ -41,6 +41,20 @@
    fi
    AC_MSG_RESULT(using $CXX)
 ])
+dnl try to build and run a dummy program
+AC_DEFUN(LFTP_CXX_TEST,
+[
+   AC_LANG_SAVE
+   AC_LANG_CPLUSPLUS
+   AC_MSG_CHECKING(if c++ compiler works)
+   AC_TRY_RUN([int main() { return(0); } ],
+           [cxx_sane=yes], [cxx_sane=no], [cxx_sane=yes])
+   AC_MSG_RESULT($cxx_sane)
+   if test x$cxx_sane = xno; then
+      AC_MSG_ERROR(C++ test compile failed; check your C++ compiler)
+   fi
+   AC_LANG_RESTORE
+])
 
 AC_DEFUN(LFTP_FUNC_SSCANF_CONST,
 [

Reply via email to