Re: [glade--]stdio.h error during compilation

Peter Wainwright <[email protected]>
Newsgroups gmane.comp.gnome.glademm
Message-ID <[email protected]>
On Fri, 2002-11-01 at 02:28, Mark Jones wrote: 

> Christof,
> 
> Do you know what might be the problem here:

I know... This looks like exactly the problem I had. It's an obscure 
autoconf problem which I probably can't explain adequately, but here 
goes: 

This is a problem I had with the configure code which tries to 
get utsname by #defining _GNU_SOURCE or __USE_GNU. 
(I'm using Red Hat 7.2 with updates). 

g++ -DHAVE_CONFIG_H -I. -I. -I.. -ISourceWriter -Iwriters -I.    -g -O2 
-c -o glade--.o `test -f 'glade--.cc' || echo './'`glade--.cc 
In file included from /usr/include/g++-3/cstdio:6, 
                 from glade--.cc:28: 
/usr/include/stdio.h:241: type specifier omitted for parameter 
/usr/include/stdio.h:241: parse error before `)' 
make[3]: *** [glade--.o] Error 1 

The problem is that when configure runs the tests, 
confdefs.h contains #include <stdlib.h>, and 
this is included BEFORE any #define lines in the test program 
conftest.cc. As a result, <stdlib.h> and the files it #includes 
will not be #included again, so the macro set in conftest.cc may 
not take effect. Thus, _GNU_SOURCE is supposed to give utsname, 
but the test does not detect this. You need to #define it before 
#including any headers... Actually __USE_GNU is supposed to be 
set automatically when you define _GNU_SOURCE, #defining it 
directly is unsupported and evil. 

Sometimes autoconf drives me mad... 

I attach a workaround. 


> 
> 
> g++ -DHAVE_CONFIG_H -I. -I. -I.. -ISourceWriter -Iwriters -I.    -g -O2
> -c glade--.cc
> In file included from /usr/include/g++-3/cstdio:6,
>                  from glade--.cc:28:
> /usr/include/stdio.h:239: type specifier omitted for parameter
> /usr/include/stdio.h:239: parse error before `)'
> 
> 
> Line 239 of stdio.h:
> 
> 
> extern FILE *fopencookie (void *__restrict __magic_cookie,
> 			  __const char *__restrict __modes,
> 			  _IO_cookie_io_functions_t __io_funcs) __THROW;
> 
> 
> If I just comment that line out in stdio.h, then it compiles and links
> just fine.  I was seeing this before, but had not mentioned it yet.  I
> had posted elsewhere wondering if I found a bug of some sort in
> stdio.h.  It belongs to package glibc-devel-2.2.5-16mdk  I have updated
> Mandrake since I installed it, tonight even, so if it is a bug, they
> have not fixed it yet I don't think.
> 
> Mark
> 
> 

-- 
       Home:                           Work:
Email: [email protected]          [email protected]
Fax:   +44-870-0523185                 +44-1235-822656
Web:   http://www.wainpr.demon.co.uk   http://www.nrpb.org
glade--.utsname.patch (text/x-patch, 1.1 KB)
diff -U3 -r glademm-1.1.2-old/configure.in glademm-1.1.2/configure.in
--- glademm-1.1.2-old/configure.in	Wed Oct 30 08:09:59 2002
+++ glademm-1.1.2/configure.in	Fri Nov  1 10:11:04 2002
@@ -74,9 +74,10 @@
 
 if test ! "x$ac_domainname_standard" = "xyes" ; then
 AC_MSG_CHECKING(whether utsname contains domainname when _GNU_SOURCE is set)
+save_CXXFLAGS="$CXXFLAGS"
+CXXFLAGS="$CXXFLAGS -D_GNU_SOURCE"
 AC_TRY_COMPILE(
 [
-#define _GNU_SOURCE
 #include <sys/utsname.h>
 ],[
    struct utsname uts;
@@ -86,15 +87,17 @@
    AC_DEFINE(HAS_DOMAINNAME)
    AC_DEFINE(_GNU_SOURCE)
 ])
+CXXFLAGS="$save_CXXFLAGS"
 AC_MSG_RESULT([$ac_domainname_gnusrc])
 fi
 
 if test "x$ac_domainname_standard" != "xyes" \
 		-a "x$ac_domainname_gnusrc$" != "xyes" ; then
 AC_MSG_CHECKING(whether utsname contains domainname when __USE_GNU is set)
+save_CXXFLAGS="$CXXFLAGS"
+CXXFLAGS="$CXXFLAGS -D__USE_GNU"
 AC_TRY_COMPILE(
 [
-#define __USE_GNU
 #include <sys/utsname.h>
 ],[
    struct utsname uts;
@@ -104,6 +107,7 @@
    AC_DEFINE(HAS_DOMAINNAME)
    AC_DEFINE(__USE_GNU)
 ])
+CXXFLAGS="$save_CXXFLAGS"
 AC_MSG_RESULT([$ac_domainname_usegnu])
 fi
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.