cclang

why there are int56_t in clang c header file, and how to use them


I noticed that

https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+/refs/heads/nougat-mr1-security-release/clang-2690385/lib64/clang/3.8/include/stdint.h#128

#ifdef __INT56_TYPE__
typedef __INT56_TYPE__ int56_t;
typedef __UINT56_TYPE__ uint56_t;
typedef int56_t int_least56_t;
typedef uint56_t uint_least56_t;
typedef int56_t int_fast56_t;
typedef uint56_t uint_fast56_t;

I searched google but find nothing. And it's even my first time to notice these types.


Solution

  • The comment in that header file before those types (link to GitHub commit adding these) explains:

    To accomodate targets that are missing types that are exactly 8, 16, 32, or 64 bits wide, this implementation takes an approach of cascading redefintions, redefining __int_leastN_t to successively smaller exact-width types. It is therefore important that the types are defined in order of descending widths.

    Whether such machines exist (anymore?) in the wild is a good question, but LLVM/clang would support them.

    In short, to answer "how to use them":

    You don't, unless you have an esoteric machine that defines __INT56_TYPE__.