Bug creation and email sending has been disabled, file new bugs at gcc.gnu.org/bugzilla
Bug 130 - Preprocessor madness with MinGW
Summary: Preprocessor madness with MinGW
Status: RESOLVED FIXED
Alias: None
Product: GDC
Classification: Unclassified
Component: gdc (show other bugs)
Version: 4.9.x
Hardware: All MinGW
: --- normal
Assignee: Iain Buclaw
URL:
Depends on:
Blocks:
 
Reported: 2014-06-11 10:32 CEST by Johannes Pfau
Modified: 2014-06-12 18:33 CEST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Pfau 2014-06-11 10:32:34 CEST
I'm updating the binary builds to GCC 4.9 right now and found a weird new bug:
I had to update the mingw64 headers and they now
#define strtod __strtod
in stdlib.h (or maybe they always did and the problem didn't show for some reason, I don't know).

As a result, our 'Port::strtod' is hijacked into 'Port::__strtod'. So far, no real problem. But it seems d-port.cc does not include the stdlib.h header so the define is not effective there. As a result I get this link error when linking cc1d:

------------------
d/lexer.dmd.o: In function `ZN5Lexer6inrealEP5Token':
/home/build/tmp/i686-w64-mingw32/.build/src/gcc-4.9.0/gcc/d/dfrontend/lexer.c:2360: undefined reference to `Port::__strtod(char const*, char**)'
collect2: error: ld returned 1 exit status

i686-gdcproject-mingw32-nm d/lexer.dmd.o | grep strto
         U __ZN4Port6strtofEPKcPPc
         U __ZN4Port7strtoldEPKcPPc
         U __ZN4Port8__strtodEPKcPPc

i686-gdcproject-mingw32-nm d/d-port.glue.o | grep strto
00000404 T __ZN4Port6strtodEPKcPPc
0000038a T __ZN4Port6strtofEPKcPPc
0000047e T __ZN4Port7strtoldEPKcPPc

------------------

I propose adding
------------------
// MinGWs stdlib.h defines strtod to __strtod.
// Depending on whether this header is included our function name changes...
#ifdef strtod
    #undef strtod
#endif
------------------
to dfrontend/port.h. What do you think Iain?