From e22b3b1de7dcdf1d1ee98a4b28eaf3a6339609ed Mon Sep 17 00:00:00 2001 From: lethosor Date: Mon, 8 Aug 2016 11:46:20 -0400 Subject: [PATCH] Use non-fixed-width types in integer identity_traits definitions In some situations (e.g. 32-bit Linux), "intptr_t" is defined as "int", which is equivalent to "int32_t", leading to issues with duplicate definitions. In other situations with GCC, "intptr_t" is "long", which isn't covered by any intNN_t types. Also, definitions for "long" already had to be added on Windows, because no fixed-width types in MSVC are equivalent to "long". Switching to non-fixed-width types should hopefully cover all of these situations. If this doesn't cover any integer types that we need, it will be caught quickly, e.g. by references to integer_traits in LuaWrapper.cpp. --- library/DataStaticsFields.cpp | 21 ++++++++------------- library/include/DataIdentity.h | 21 ++++++++------------- 2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/library/DataStaticsFields.cpp b/library/DataStaticsFields.cpp index 11a270251..8ff0770fc 100644 --- a/library/DataStaticsFields.cpp +++ b/library/DataStaticsFields.cpp @@ -18,21 +18,16 @@ namespace df { #ifndef STATIC_FIELDS_GROUP INTEGER_IDENTITY_TRAITS(char); - INTEGER_IDENTITY_TRAITS(int8_t); - INTEGER_IDENTITY_TRAITS(uint8_t); - INTEGER_IDENTITY_TRAITS(int16_t); - INTEGER_IDENTITY_TRAITS(uint16_t); - INTEGER_IDENTITY_TRAITS(int32_t); - INTEGER_IDENTITY_TRAITS(uint32_t); - INTEGER_IDENTITY_TRAITS(int64_t); - INTEGER_IDENTITY_TRAITS(uint64_t); -#ifdef _WIN32 + INTEGER_IDENTITY_TRAITS(signed char); + INTEGER_IDENTITY_TRAITS(unsigned char); + INTEGER_IDENTITY_TRAITS(short); + INTEGER_IDENTITY_TRAITS(unsigned short); + INTEGER_IDENTITY_TRAITS(int); + INTEGER_IDENTITY_TRAITS(unsigned int); INTEGER_IDENTITY_TRAITS(long); INTEGER_IDENTITY_TRAITS(unsigned long); -#else - INTEGER_IDENTITY_TRAITS(intptr_t); - INTEGER_IDENTITY_TRAITS(uintptr_t); -#endif + INTEGER_IDENTITY_TRAITS(long long); + INTEGER_IDENTITY_TRAITS(unsigned long long); FLOAT_IDENTITY_TRAITS(float); FLOAT_IDENTITY_TRAITS(double); diff --git a/library/include/DataIdentity.h b/library/include/DataIdentity.h index a04311ac4..556731e46 100644 --- a/library/include/DataIdentity.h +++ b/library/include/DataIdentity.h @@ -516,21 +516,16 @@ namespace df #define FLOAT_IDENTITY_TRAITS(type) NUMBER_IDENTITY_TRAITS(float, type) INTEGER_IDENTITY_TRAITS(char); - INTEGER_IDENTITY_TRAITS(int8_t); - INTEGER_IDENTITY_TRAITS(uint8_t); - INTEGER_IDENTITY_TRAITS(int16_t); - INTEGER_IDENTITY_TRAITS(uint16_t); - INTEGER_IDENTITY_TRAITS(int32_t); - INTEGER_IDENTITY_TRAITS(uint32_t); - INTEGER_IDENTITY_TRAITS(int64_t); - INTEGER_IDENTITY_TRAITS(uint64_t); -#ifdef _WIN32 + INTEGER_IDENTITY_TRAITS(signed char); + INTEGER_IDENTITY_TRAITS(unsigned char); + INTEGER_IDENTITY_TRAITS(short); + INTEGER_IDENTITY_TRAITS(unsigned short); + INTEGER_IDENTITY_TRAITS(int); + INTEGER_IDENTITY_TRAITS(unsigned int); INTEGER_IDENTITY_TRAITS(long); INTEGER_IDENTITY_TRAITS(unsigned long); -#else - INTEGER_IDENTITY_TRAITS(intptr_t); - INTEGER_IDENTITY_TRAITS(uintptr_t); -#endif + INTEGER_IDENTITY_TRAITS(long long); + INTEGER_IDENTITY_TRAITS(unsigned long long); FLOAT_IDENTITY_TRAITS(float); FLOAT_IDENTITY_TRAITS(double);