12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- #ifndef BASIC_TYPES_HEADER
- #define BASIC_TYPES_HEADER
- // at start, this library expects that the system
- // follows the 1 byte = 8 bits "accepted convention"
- #ifndef CHAR_BIT
- #define CHAR_BIT 8
- #endif
- // minimum integers
- // char is the fundamental space unit
- // it is expected to be 1 byte long
- // typedef char char;
- typedef unsigned char byte;
- #define CHAR_SIZE sizeof(char)
- #define BYTE_SIZE sizeof(byte)
- // largest integers. I hope
- // they are at least 32 bits long
- typedef long long smax;
- typedef unsigned long long umax;
- #define SMAX_SIZE sizeof(smax)
- #define UMAX_SIZE sizeof(umax)
- // max float type (I expect it to be a 32 or 64 bits float)
- // won't use long double since I don't want to deal with
- // 12 bytes doubles implemented by some compilers
- typedef double fmax;
- #define FMAX_SIZE sizeof(fmax)
- // custom boolean type
- typedef char bool;
- #define BOOL_SIZE sizeof(bool)
- #define true 1
- #define false 0
- // NOTE: enums will be declared in UPPERCASE
- // to be able to distinguish them from
- // other variable types easily
- // var_basic_types enum
- // the first variable types enum
- // all other variable types enums will continue this one
- // so it is like an "extensible" variable type enum
- typedef enum
- {
- VAR_CHAR,
- VAR_BYTE,
- VAR_SMAX,
- VAR_UMAX,
- VAR_FMAX,
- VAR_BOOL,
- VAR_BASIC_TYPES
- } var_basic_types;
- // mask enum as an integer type for
- // variable type function arguments
- typedef var_basic_types var_type;
- // creating and destroying is not
- // necessary with these simple data types
- umax print_byte_dec(byte * src, umax size);
- umax print_byte_hex(byte * src, umax size);
- umax print_char(byte * src, umax size);
- umax print_umax_dec(byte * src, umax size);
- umax print_umax_hex(byte * src, umax size);
- umax print_smax(byte * src, umax size);
- umax print_fmax(byte * src, umax size);
- umax print_bool(byte * src, umax size);
- #include "BASIC_TYPES.c"
- #endif // BASIC_TYPES_HEADER
|