I am writing a cross-platform library for my own use. The library can be used in linux kernel, NT kernel, and many other environments, so I don't want to be dependent on any headers or libraries, even if they are standard headers. So, I cannot include stdint.h
to use int32_t
.
If I use VC++, I can typedef __int32 MY_INT32;
, because __int32
is built in the compiler.
Is there a counterpart of __int32
in GCC?
My current practice is:
typedef signed char KTL_INT8;
typedef signed short KTL_INT16;
typedef signed int KTL_INT32;
typedef signed long long KTL_INT64;
typedef unsigned char KTL_UINT8;
typedef unsigned short KTL_UINT16;
typedef unsigned int KTL_UINT32;
typedef unsigned long long KTL_UINT64;
static_assert(1 == sizeof(KTL_INT8), "sizeof(KTL_INT8) != 1");
static_assert(2 == sizeof(KTL_INT16), "sizeof(KTL_INT16) != 2");
static_assert(4 == sizeof(KTL_INT32), "sizeof(KTL_INT32) != 4");
static_assert(8 == sizeof(KTL_INT64), "sizeof(KTL_INT64) != 8");