Add compile time tests for int.h

This commit is contained in:
Lucas Schumacher 2025-04-24 22:57:02 -04:00
parent 0eaae16280
commit cbd613e068

34
int.h
View File

@ -21,3 +21,37 @@ typedef uint64_t uintptr_t;
typedef int32_t intptr_t;
typedef uint32_t uintptr_t;
#endif
// Compile time tests in supported compilers
#ifdef __SIZEOF_CHAR__
#if __SIZEOF_CHAR__ != 1
#error __SIZEOF_CHAR__ is not 1
#endif
#endif
#ifdef __SIZEOF_SHORT__
#if __SIZEOF_SHORT__ != 2
#error __SIZEOF_SHORT__ is not 2
#endif
#endif
#ifdef __SIZEOF_INT__
#if __SIZEOF_INT__ != 4
#error __SIZEOF_INT__ is not 4
#endif
#endif
#ifdef __SIZEOF_LONG_LONG__
#if __SIZEOF_LONG_LONG__ != 8
#error __SIZEOF_LONG_LONG__ is not 8
#endif
#endif
#ifdef __SIZEOF_POINTER__
#if __SIZEOF_POINTER__ != (__WORDSIZE / 8)
#error __SIZEOF_POINTER__ is not (__WORDSIZE / 8)
#endif
#endif
//TODO:
//#ifdef __SIZEOF_SIZE_T__