[LLVMdev] [PATCH]: MSVC build enhancements

OvermindDL1 overminddl1 at gmail.com
Sat Mar 6 15:27:21 PST 2010


To the mailing list this time...

On Sat, Mar 6, 2010 at 4:26 PM, OvermindDL1 <overminddl1 at gmail.com> wrote:
> On Sat, Mar 6, 2010 at 4:19 PM, José Fonseca <jose.r.fonseca at gmail.com> wrote:
>>>> --- a/include/llvm/System/DataTypes.h.cmake
>>>> +++ b/include/llvm/System/DataTypes.h.cmake
>>>> @@ -100,6 +100,9 @@ typedef u_int64_t uint64_t;
>>>>  #else
>>>>  #include <math.h>
>>>>  #endif
>>>> +#ifdef HAVE_STDINT_H
>>>> +#include <stdint.h>
>>>> +#else /* !HAVE_STDINT_H */
>>>
>>> This looks incorrect to me. stdint.h is already included below for
>>> non-MSVC systems. Maybe you inteded to #include it for MSVC only? Or do
>>> intend to correct some problem with non-MSVC builds too?
>>
>> The idea here is indeed to use an external stdint.h in MSVC builds.
>>
>> The problem is that everybody except Microsoft recognized the
>> usefulness of stdint.h types [1], and they work around it for MSVC by
>> defining the stdint.h types themselves. LLVM does it. Mesa3D did it
>> too. But that won't work when two such projects try to interoperate --
>> you'll get errors that uint8_t/uint16_t/uint32_t/etc has been
>> redefined.
>>
>> There is more than one way to address this. The solution I came up
>> with was to make all projects respect HAVE_STDINT_H, and only define
>> the stdint types if HAVE_STDINT_H is not defined. Then all projects
>> can use the same definition, without symbol clashes. We actually ship
>> a tiny stdint.h in Mesa3D,
>> http://cgit.freedesktop.org/mesa/mesa/tree/include/c99/stdint.h , but
>> there are many free replacements out there.
>>
>> This is not a problem specific to Mesa and LLVM -- it is a problem
>> faced by any pair of projects that use stdint types and want to build
>> on MSVC.
>>
>> Jose
>>
>> [1] I'm being unfair. Microsoft certainly recognized by now how useful
>> the stdint.h types are to write portable code, which is probably the
>> reason why they haven't been implemented yet. It doesn't appear C99
>> will be implemented soon either:
>> https://connect.microsoft.com/VisualStudio/feedback/details/485416/support-c99
>
> Boost has such an stdint compatibility header in their TR1 section.
> Why not take it and put it in LLVM itself, the boost license
> encourages that use and it interoperates properly with every known
> compiler, adding the missing things on those compilers if necessary.
>




More information about the llvm-dev mailing list