[cfe-dev] math.h on Windows

John Thompson john.thompson.jtsoftware at gmail.com
Tue Oct 13 13:02:15 PDT 2009


There is a compile error when compiling VC++'s math.h.

Apparently, the GNU extentions are still enabled by default for Windows VC++
builds, in particular "_Complex".

This conflicts with the parameter name in:

_CRTIMP double  __cdecl _cabs(__in struct _complex _Complex);

During my investigation, I tried turning off the GNU extensions when the
Microsoft extensions are enabled, but this is problematic with a number of
the tests, which use _Complex, and probably lots of other places.  This
raised the question in my mind as to whether the GNU extensions should be
enabled in this case, but I figure it's probably better that way, making the
compiler more flexible.

Therefore, one way to make this work would be to change the parser a bit to
detect this case, and treat the _Complex token as an identifier in this
case.  The error originates from line 410 of DeclSpec.cpp.
Would this be a reasonable solution?

I haven't looked in to how to do this yet, but if you think it's a good
idea, I'll attempt it.

Actually, today there are two other errors in compiling this file, related
to wchar_t being defined already.  One solution is to define
_WCHAR_T_DEFINED for the Visual Studio targets, which will disable the
conflicting definition in crtdefs.h, and possibly elsewhere.  The enclosed
patch does this, which if you will approve it, I'll check it in.

To make the tests less dependent on headers, I've also enclosed a
mathtest.patch file for eliminating the math.h inclusion in the failed tests
I've looked at so far.

-John

-- 
John Thompson
John.Thompson.JTSoftware at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20091013/44f32f7d/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wchart.patch
Type: application/octet-stream
Size: 951 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20091013/44f32f7d/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mathtest.patch
Type: application/octet-stream
Size: 1447 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20091013/44f32f7d/attachment-0001.obj>


More information about the cfe-dev mailing list