[llvm-commits] [llvm] r58048 - in /llvm/trunk: include/llvm/Support/DataTypes.h.in win32/VMCore/VMCore.vcproj win32/clang.sln

Ted Kremenek kremenek at apple.com
Fri Oct 24 14:53:05 PDT 2008


On Oct 24, 2008, at 11:47 AM, Kenneth Boyd wrote:

> Ted Kremenek wrote:
>> On Oct 23, 2008, at 4:28 PM, Steve Naroff wrote:
>>
>>
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> ====================================================================
>>> --- llvm/trunk/include/llvm/Support/DataTypes.h.in (original)
>>> +++ llvm/trunk/include/llvm/Support/DataTypes.h.in Thu Oct 23
>>> 18:28:23 2008
>>> @@ -37,6 +37,11 @@
>>> # error "Must #define __STDC_LIMIT_MACROS before #including Support/
>>> DataTypes.h"
>>> #endif
>>>
>>> +#if !defined(__STDC_CONSTANT_MACROS)
>>> +# error "Must #define __STDC_CONSTANT_MACROS before " \
>>> +        "#including Support/DataTypes.h"
>>> +#endif
>>> +
>>>
>>
>> Hi Steve,
>>
>> This breaks building Clang in Xcode (164 errors).  Everywhere that
>> DataTypes.h is included I see the error "Must #define
>> __STDC_CONSTANT_MACROS before #including Support/DataTypes.h".  What
>> was the motivation for these lines?
>>
> C99 and the current C0X draft both have a bogus suggestion [C99  
> footnote
> 220 to 7.18.2p1] (prohbited by C++0X 18.3.1p2, do not have C++03 on  
> hand
> to check) that this macro be defined to enable a number of macros in
> stdint.h in C++.  [E.g., the INT64_C macro.]  As this suggestion has  
> no
> observable effect in a C program, it should be removed from C0X.
>
> I'm certain I'm not the first to have this idea, so I would want to
> research whether this has been officially rejected before proposing  
> it.
>
> In my opinion, the correct way to handle this is to test for the
> definition of the INT64_C macro after including stdint.h.  If  
> INT64_C is
> not defined, then you know you have a broken stdint.h and should error
> immediately.
>
> If furthermore __STDC_CONSTANT_MACROS is not defined, then we can
> suggest that could be the problem (it would fix the problem on GCC,
> which has a C99-compliant stdint.h).
>
> Kenneth

Thanks Kenneth.

I noticed that "__STDC_CONSTANT_MACROS" is explicitly passed as a -D  
option by make:

Makefile.rules:CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_LIMIT_MACROS - 
D__STDC_CONSTANT_MACROS

Modifying the Xcode project to also add this option is trivial; I'm  
not certain if your last comment implies that the compiler (gcc)  
should be defining __STDC_CONSTANT_MACROS on its own.






More information about the llvm-commits mailing list