In converting some cross-platform C++ projects from VS 2008 to Visual Studio 2010, we've tried out some of the new standard libraries that VS 2010 now uses, instead of defining our own for Windows. One of those is stdint.hHowever, stdint.h defines INT64_C and UINT64_C in a way that isn't fully compatible with Linux and Mac. The VS 2010 version of INT64_C and UINT64_C looks like:#define INT64_C(x) ((x) + (INT64_MAX - INT64_MAX))#define UINT64_C(x) ((x) + (UINT64_MAX - UINT64_MAX))However, on Linux for example, its defined this way:/* Signed. */# define INT8_C(c) c# define INT16_C(c) c# define INT32_C(c) c# if __WORDSIZE == 64# define INT64_C(c) c ## L# else# define INT64_C(c) c ## LL# endif/* Unsigned. */# define UINT8_C(c) c# define UINT16_C(c) c# define UINT32_C(c) c ## U# if __WORDSIZE == 64# define UINT64_C(c) c ## UL# else# define UINT64_C(c) c ## ULL# endifand on Mac, this way:#define INT8_C(v) (v)#define INT16_C(v) (v)#define INT32_C(v) (v)#define INT64_C(v) (v ## LL)#define UINT8_C(v) (v ## U)#define UINT16_C(v) (v ## U)#define UINT32_C(v) (v ## U)#define UINT64_C(v) (v ## ULL)The problem with the VS 2010 definition, is that code like:#define ONEDAY_REFERENCETIME INT64_C(24 * 60 * 60 * 10000000)...class Test{public: Test() : m_value(ONEDAY_REFERENCETIME) { }private: REFERENCE_TIME m_value;};has a warning:warning C4307: '*' : integral constant overflowInstead of the current definition, VS 2010 and later should use a more compatible definition:/* Signed. */#define INT8_C(c) c#define INT16_C(c) c#define INT32_C(c) c#define INT64_C(c) c ## i64/* Unsigned. */#define UINT8_C(c) c ## U#define UINT16_C(c) c ## U#define UINT32_C(c) c ## U#define UINT64_C(c) c ## ui64
Visual Studio/Team Foundation Server/.NET Framework Tooling version
Steps to reproduce
Product Language
Operating System
Operating System Language
Actual results
Expected results
Please wait...