[Pw_forum] Error building q-e 4.1 with Ubuntu 9.10 beta
James J Ramsey
jjr19 at zips.uakron.edu
Mon Oct 5 18:54:25 CEST 2009
2009/10/3 Miguel Martínez <miguel.martinez at ehu.es>:
> It seems that if I comment out the test regarding HAVE_MALLINFO in
> configure (lines 4085 to 4090) and reconfigure, the compilation will
> produce useful binaries. Does anybody know what's happening here? Is
> this (another) ubuntu bug?
The problem seems to happen in memstat.c, and there's one part of it
that looks fishy to me:
void F77_FUNC(memstat,MEMSTAT)(int *kilobytes)
{
#if defined (__SVR4) && defined (__sun)
#define SUN_MALLINFO
#endif
#if defined(HAVE_MALLINFO) && !defined(__QK_USER__) && !defined(SUN__MALLINFO)
#include <malloc.h>
struct mallinfo info;
info = mallinfo();
#if defined(__AIX)
*kilobytes = (info.arena) / 1024 ;
#else
*kilobytes = (info.arena + info.hblkhd) / 1024 ;
#endif
#else
*kilobytes = -1;
#endif
}
The #include statement is *inside* a function, and while I'm no expert
in C, I think that explains the error messages about nested functions
declared "extern". I noticed, for example, that in my copy of
/usr/include/bits/stdio.h on Ubuntu 8.04, the getchar definition looks
like this:
/* Read a character from stdin. */
__STDIO_INLINE int
getchar (void)
{
return _IO_getc (stdin);
}
and the macro __STDIO_INLINE is defined as follows:
#ifndef __extern_inline
# define __STDIO_INLINE inline
#else
# define __STDIO_INLINE __extern_inline
#endif
My guess, but one that could easily be wrong, is that the #include
statement inside the function was tolerated before because the macro
__STDIO_INLINE was expanded to "inline," but now the function ends up
declared "extern". In any case, judging from a post on the gcl-devel
list (http://www.mail-archive.com/gcl-devel@gnu.org/msg02038.html),
that #include statement inside the function was a time bomb. From the
post:
Then GCL is buggy. Standard headers are never meant to be included
inside of a function. E.g. ISO C99 says in 7.1.2/4:
... "If used, a header shall be included outside of any external
declaration or
definition, and it shall first be included before the first
reference to any of
the functions or objects it declares, or to any of the types or macros it
defines."...
I'd say that memstat.c needs to be fixed.
University of Akron
Computer Modeling & Simulation
Civil Engineering Dept.
More information about the users
mailing list