diff options
author | Paul Oliver <contact@pauloliver.dev> | 2024-02-29 02:29:13 +0100 |
---|---|---|
committer | Paul Oliver <contact@pauloliver.dev> | 2024-02-29 02:29:13 +0100 |
commit | ca118555214a176728b9aab87849391344306d6d (patch) | |
tree | 833cffdd4066a7114b1d79d6eeaa2e0152408fc8 /include/types.h |
Initial commit.
Diffstat (limited to 'include/types.h')
-rw-r--r-- | include/types.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/include/types.h b/include/types.h new file mode 100644 index 0000000..3ae418f --- /dev/null +++ b/include/types.h @@ -0,0 +1,45 @@ +/** +* @file types.h +* @author Paul Oliver +* +* Declare main typedefs for the Salis library. Salis depends on fixed-width +* unsigned types being available. We use the limits header to define these in +* a C89 compliant way. Also, we typedef respective pointer types and a string +* type to aid in header parsing. +*/ + +#ifndef SALIS_TYPES_H +#define SALIS_TYPES_H + +#include <limits.h> + +#define UINT8_MAX 0xff +#define UINT32_MAX 0xffffffff + +#if UCHAR_MAX == UINT8_MAX + typedef unsigned char uint8; + typedef unsigned char *uint8_p; +#else + #error "Cannot define uint8/uint8_p types!" +#endif + +#if ULONG_MAX == UINT32_MAX + typedef unsigned long int uint32; + typedef unsigned long int *uint32_p; +#elif UINT_MAX == UINT32_MAX + typedef unsigned int uint32; + typedef unsigned int *uint32_p; +#elif USHRT_MAX == UINT32_MAX + typedef unsigned short int uint32; + typedef unsigned short int *uint32_p; +#else + #error "Cannot define uint32/uint32_p types!" +#endif + +typedef int boolean; +typedef const char *string; + +#define TRUE 1 +#define FALSE 0 + +#endif |