[llvm-commits] MSVC cstdint

OvermindDL1 overminddl1 at gmail.com
Tue May 12 14:14:06 PDT 2009


In the llvm file include/llvm/Support/DataTypes.h (.in/.cmake), for
MSVCit defines some macros that are defined in the cstdint.hpp file in
boost (and boost does it better, detailed below):

The basic error is:
R:\SDKs\boost\built_head\include\boost-1_38\boost/cstdint.hpp(347) :
warning C4005: 'INT8_C' : macro redefinition
        R:\SDKs\llvm\trunk_VC8_building\include\llvm/Support/DataTypes.h(116)
: see previous definition of 'INT8_C'
R:\SDKs\boost\built_head\include\boost-1_38\boost/cstdint.hpp(348) :
warning C4005: 'INT16_C' : macro redefinition
        R:\SDKs\llvm\trunk_VC8_building\include\llvm/Support/DataTypes.h(118)
: see previous definition of 'INT16_C'
R:\SDKs\boost\built_head\include\boost-1_38\boost/cstdint.hpp(349) :
warning C4005: 'INT32_C' : macro redefinition
        R:\SDKs\llvm\trunk_VC8_building\include\llvm/Support/DataTypes.h(120)
: see previous definition of 'INT32_C'
R:\SDKs\boost\built_head\include\boost-1_38\boost/cstdint.hpp(350) :
warning C4005: 'INT64_C' : macro redefinition
        R:\SDKs\llvm\trunk_VC8_building\include\llvm/Support/DataTypes.h(122)
: see previous definition of 'INT64_C'
R:\SDKs\boost\built_head\include\boost-1_38\boost/cstdint.hpp(355) :
warning C4005: 'UINT8_C' : macro redefinition
        R:\SDKs\llvm\trunk_VC8_building\include\llvm/Support/DataTypes.h(117)
: see previous definition of 'UINT8_C'
R:\SDKs\boost\built_head\include\boost-1_38\boost/cstdint.hpp(357) :
warning C4005: 'UINT16_C' : macro redefinition
        R:\SDKs\llvm\trunk_VC8_building\include\llvm/Support/DataTypes.h(119)
: see previous definition of 'UINT16_C'
R:\SDKs\boost\built_head\include\boost-1_38\boost/cstdint.hpp(358) :
warning C4005: 'UINT32_C' : macro redefinition
        R:\SDKs\llvm\trunk_VC8_building\include\llvm/Support/DataTypes.h(121)
: see previous definition of 'UINT32_C'
R:\SDKs\boost\built_head\include\boost-1_38\boost/cstdint.hpp(359) :
warning C4005: 'UINT64_C' : macro redefinition
        R:\SDKs\llvm\trunk_VC8_building\include\llvm/Support/DataTypes.h(123)
: see previous definition of 'UINT64_C'

LLVMs definitions look like this:
#define INT8_C(C)   C
#define UINT8_C(C)  C
#define INT16_C(C)  C
#define UINT16_C(C) C
#define INT32_C(C)  C
#define UINT32_C(C) C ## U
#define INT64_C(C)  ((int64_t) C ## LL)
#define UINT64_C(C) ((uint64_t) C ## ULL)

Boosts look like this:
#  define INT8_C(value)     value##i8
#  define INT16_C(value)    value##i16
#  define INT32_C(value)    value##i32
#  define INT64_C(value)    value##i64
#  define UINT8_C(value)    value##ui8
#  define UINT16_C(value)   value##ui16
#  define UINT32_C(value)   value##ui32
#  define UINT64_C(value)   value##ui64
#  define INTMAX_C(value)   value##i64
#  define UINTMAX_C(value)  value##ui64
Which is more correct due to MSVC suffix (boost also defines
appropriate ones for appropriate compilers).  My main thing is the
warnings, which were not there earlier, although I have had boost for
far longer.  looking in the log it appears this was broke on revision
58048, where before it only defined UINT64_C, but it had a guard
around it, the exact lines where:
#if !defined(INT64_C)
# define INT64_C(val) val##LL
#endif

Since these are rather well used defines, would it be possible to use
the MSVC specific suffixes since these are in the MSVC specific
section, as well as putting include guards around each of them?  See
the attached patch that does both.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: stdint_fix.patch
Type: application/octet-stream
Size: 2425 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20090512/03232d5b/attachment.obj>


More information about the llvm-commits mailing list