long and int64 overloads

The following code appears in BasicTypes.h of cxUtils project. It can be uncommented out to see various predefined macros which identify the target platform.


#define CEDA_STRINGIZE_MACRO(m) #m
#define CEDA_MAKE_STRING( M, L ) M(L)
#define CEDA_SHOW_MACRO(m) "----------------- " #m " = " CEDA_MAKE_STRING( CEDA_STRINGIZE_MACRO, m )

#pragma message(CEDA_SHOW_MACRO(__GNUC__))

#pragma message(CEDA_SHOW_MACRO(__linux__))
#pragma message(CEDA_SHOW_MACRO(_WIN32))
#pragma message(CEDA_SHOW_MACRO(__ANDROID__))

#pragma message(CEDA_SHOW_MACRO(__amd64__))
#pragma message(CEDA_SHOW_MACRO(_M_X64))
#pragma message(CEDA_SHOW_MACRO(_M_AMD64))
#pragma message(CEDA_SHOW_MACRO(__x86_64__))
#pragma message(CEDA_SHOW_MACRO(__IA32__))

#pragma message(CEDA_SHOW_MACRO(__i386__))
#pragma message(CEDA_SHOW_MACRO(__i486__))
#pragma message(CEDA_SHOW_MACRO(__i586__))
#pragma message(CEDA_SHOW_MACRO(__i686__))

#pragma message(CEDA_SHOW_MACRO(__arm__))
#pragma message(CEDA_SHOW_MACRO(_M_ARM))

#pragma message(CEDA_SHOW_MACRO(__ARM_ARCH_2__))
#pragma message(CEDA_SHOW_MACRO(__ARM_ARCH_3__))
#pragma message(CEDA_SHOW_MACRO(__ARM_ARCH_3M__))
#pragma message(CEDA_SHOW_MACRO(__ARM_ARCH_4T__))
#pragma message(CEDA_SHOW_MACRO(__ARM_ARCH_5__))
#pragma message(CEDA_SHOW_MACRO(__ARM_ARCH_5E__))
#pragma message(CEDA_SHOW_MACRO(__ARM_ARCH_5T__))
#pragma message(CEDA_SHOW_MACRO(__ARM_ARCH_5TE__))
#pragma message(CEDA_SHOW_MACRO(__ARM_ARCH_5TEJ__))
#pragma message(CEDA_SHOW_MACRO(__ARM_ARCH_6__))
#pragma message(CEDA_SHOW_MACRO(__ARM_ARCH_6J__))
#pragma message(CEDA_SHOW_MACRO(__ARM_ARCH_6K__))
#pragma message(CEDA_SHOW_MACRO(__ARM_ARCH_6Z__))
#pragma message(CEDA_SHOW_MACRO(__ARM_ARCH_6ZK__))
#pragma message(CEDA_SHOW_MACRO(__ARM_ARCH_6T2__))
#pragma message(CEDA_SHOW_MACRO(__ARM_ARCH_7__))
#pragma message(CEDA_SHOW_MACRO(__ARM_ARCH_7A__))
#pragma message(CEDA_SHOW_MACRO(__ARM_ARCH_7R__))
#pragma message(CEDA_SHOW_MACRO(__ARM_ARCH_7M__))
#pragma message(CEDA_SHOW_MACRO(__ARM_ARCH_7S__))
#pragma message(CEDA_SHOW_MACRO(__ARM_ARCH_8__))
#pragma message(CEDA_SHOW_MACRO(__ARM_ARCH_8A__))

#pragma message(CEDA_SHOW_MACRO(__aarch64__))

#pragma message(CEDA_SHOW_MACRO(__mips__))
#pragma message(CEDA_SHOW_MACRO(_MIPS_ISA))
#pragma message(CEDA_SHOW_MACRO(_R3000))
#pragma message(CEDA_SHOW_MACRO(_R4000))
#pragma message(CEDA_SHOW_MACRO(_R5900))

When targeting arm64-v8a it was found that __ARM_ARCH_8A__ isn't actually defined, but __aarch64__ is defined.

In the CEDA source code there are overloads like put on xostream, and it's useful to know whether int64 and long are distinct types. This leads to the following code:


#if defined(__GNUC__) && defined(__linux__) && (defined(__x86_64__) || defined(_MIPS_ISA) && _MIPS_ISA == _MIPS_ISA_MIPS64) || defined(__aarch64__)
    // On this platform __INT64_TYPE__ is the same as long so we cannot distinguish overloads of
    // long and int64
    #define CEDA_DEFINE_LONG_OVERLOAD 0
#else
    #define CEDA_DEFINE_LONG_OVERLOAD 1
#endif