TR_datastructures 0.1.0
A generic C data structures library
Loading...
Searching...
No Matches
Macros | Enumerations
tr_types.h File Reference

Portable type definitions for C89/C99/C11 compatibility. More...

#include <limits.h>
#include <stddef.h>

Go to the source code of this file.

Macros

#define TR_STATIC_ASSERT(condition, message)    typedef char tr_static_assert_##message[(condition) ? 1 : -1]
 Compile time assertion macro.
 
#define NULL   ((void *) 0)
 Null pointer constant.
 

Enumerations

enum  bool { false = 0 , true = 1 }
 Boolean type. More...
 

Detailed Description

Portable type definitions for C89/C99/C11 compatibility.

Provides fixed width integer types, bool, and NULL for use across all C standards. On C99 and later the standard headers are used directly. On C89 portable fallbacks are provided with compile time size verification.

Macro Definition Documentation

◆ TR_STATIC_ASSERT

#define TR_STATIC_ASSERT (   condition,
  message 
)     typedef char tr_static_assert_##message[(condition) ? 1 : -1]

Compile time assertion macro.

Triggers a compile error if condition is false. On C11 and later uses _Static_assert. On C89/C99 uses the array size trick.

Parameters
conditionExpression to evaluate at compile time
messageToken used as the error identifier — no spaces allowed

Example usage:

TR_STATIC_ASSERT(sizeof(int) == 4, int_must_be_4_bytes);
#define TR_STATIC_ASSERT(condition, message)
Compile time assertion macro.
Definition tr_types.h:73

Enumeration Type Documentation

◆ bool

enum bool

Boolean type.

On C++ uses the native bool type. On C99 and later includes stdbool.h. On C89 provides a portable enum fallback with values false = 0 and true = 1, matching C99 exactly.

Enumerator
false 

Boolean false value - evaluates to 0

true 

Boolean true value - evaluates to 1