2022-11-25

c data types

part of c programming

  • types can be understood as a memory space requirement and semantics for accessing the memory
  • for example, an unsigned integer type and a pointer might store a identical sequence of bits, yet pointers increment in address step sizes
  • the standard types int, char, and more have a platform dependent variable size with a minimum required size. type prefixes (long, long long, short, short short) are available to adjust the minimum size requirements. c data types on wikipedia
  • there are also standard fixed size data types that are usually defined in the file stdint.h and included with inttypes.h. these types are for example int32_t, uint8_t and more. they do not take the somewhat strange "long long" and related type prefixes. inttypes.h also defines minimum size and maximum size limited types (int_least32_t, intmax_t, etc) as well as a fast type which is guaranteed to be the fastest available type on a platform of a minimum size

shorter type names

here are some alternative type names that could be used:

i8 i16 i32 i64 i8_least i16_least i32_least i64_least
i8_fast i16_fast i32_fast i64_fast u8 u16 u32 u64 u8
u16_least u32_least u64_least u8_fast u16_fast u32_fast
u64_fast f32 float f64 double pointer boolean

incidentally, the rust language uses some of these type names