nullable.h 453 B

1234567891011121314151617
  1. #pragma once
  2. #include <stdint.h>
  3. #include <stdbool.h>
  4. #define TOTP_NULLABLE_STRUCT(value_type) \
  5. typedef struct TotpNullable_##value_type { \
  6. bool is_null; \
  7. value_type value; \
  8. } TotpNullable_##value_type
  9. #define TOTP_NULLABLE_NULL(s) s.is_null = true
  10. #define TOTP_NULLABLE_VALUE(s, v) \
  11. s.is_null = false; \
  12. s.value = v
  13. TOTP_NULLABLE_STRUCT(uint16_t);