Compile error: function name collisions between port.h and math.h?

Thomas Kuehne thomas-dloop at kuehne.cn
Thu Apr 5 01:27:32 PDT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

mpb schrieb am 2007-04-05:
> Hi,
>
> I get a compile error when I try to compile GDC 0.23 against GCC
> 4.0.1, 4.0.4, 4.1.1 or 4.1.2.

I've successfully compiled gdc-0.23 with vanilla 4.1.2 as well as
a Gentoo patched 4.1.2. 

> ./gcc/d/dmd/port.h:37: error: expected unqualified-id before 'sizeof'
> ./gcc/d/dmd/port.h:37: error: expected `)' before 'sizeof'
> ./gcc/d/dmd/port.h:38: error: expected unqualified-id before 'sizeof'
> ./gcc/d/dmd/port.h:38: error: expected `)' before 'sizeof'
> ./gcc/d/dmd/port.h:40: error: expected unqualified-id before 'sizeof'
> ./gcc/d/dmd/port.h:40: error: expected `)' before 'sizeof'
>
> GCC (without D) compiles fine.  I'm running on Linux 2.6.12 with glibc
> 2.4 and compiling with GCC 4.1.1.

Judging from the messages below you might be compiling with 4.1.1 but
the gcc you are compiling seems to be 4.0.4.

> port.h lines 37 through 40 are part of the declaration of struct Port:
>
>     static int isnan(double);
>     static int isfinite(double);
>     static int isinfinity(double);
>     static int signbit(double);
>
> It is interesting that line 39, while very similar, does not generate
> an error.
>
> The command that causes the error is:
>
> c++   -O2 -march=i686 -fomit-frame-pointer -pipe -DIN_GCC   -W -Wall
> -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes     -DHAVE_CONFIG_H
> -I. -Id -I/home/zu20070220/Files/Compile/Sources/gcc-4.0.4/./gcc
> -I/home/zu20070220/Files/Compile/Sources/gcc-4.0.4/./gcc/d
> -I/home/zu20070220/Files/Compile/Sources/gcc-4.0.4/./gcc/../include
> -I/home/zu20070220/Files/Compile/Sources/gcc-4.0.4/./gcc/../libcpp/include
>  -Id -I/home/zu20070220/Files/Compile/Sources/gcc-4.0.4/./gcc/d/dmd
> -I/home/zu20070220/Files/Compile/Sources/gcc-4.0.4/./gcc/d -D_GNU_SOURCE=1
> -D_DH=1 -DD_NO_TRAMPOLINES=1 -DELFOBJ=1 -DD_GCC_VER=40 -Wno-missing-braces
> -fmessage-length=0 -include
> /home/zu20070220/Files/Compile/Sources/gcc-4.0.4/./gcc/d/dmd/total.h -o
> d/expression.dmd.o -c
> /home/zu20070220/Files/Compile/Sources/gcc-4.0.4/./gcc/d/dmd/expression.c
>
> The command also generates approximately 180 warnings.
>
> The errors might be due to collisions with similarly named functions
> in math.h.

The problem is that <math.h> doesn't define a function for isnan but a
macro.

Lets try to edit d/dmd/expression.c:
Move "#include <math.h>" to line 60 and try to recompile.

Thomas


-----BEGIN PGP SIGNATURE-----

iD8DBQFGFL47LK5blCcjpWoRAnJUAJ91wrowDxjXmrJM8cvJKRz3qZtnEACfamF4
5uTXF1JBB3wrCF1wIC+0v+s=
=1K1E
-----END PGP SIGNATURE-----


More information about the D.gnu mailing list