C Tool Box 0.1.0
Loading...
Searching...
No Matches
ctb.h File Reference

Go to the source code of this file.

Macros

#define ctb_arr(itemType, length)
 Creates an array of the given type and length.
 
#define ctb_obj(type)
 Creates an object of the given type and initializes it with zeros.
 
#define ctb_lengthOf(arr)
 Calculates the length of the given array.
 
#define ctb_containerOf(obj, type, member)
 Calculates the address of the containing object.
 
#define ctb_staticAssert(expression, identifier)
 Generates a compile-time assertion.
 

Macro Definition Documentation

◆ ctb_arr

#define ctb_arr ( itemType,
length )
Value:
((itemType[length]){ 0 })

Creates an array of the given type and length.

Parameters
itemTypeType of each item in the array
lengthNumber of items in the array

◆ ctb_containerOf

#define ctb_containerOf ( obj,
type,
member )
Value:
((type *)((char *)(obj) - offsetof(type, member)))

Calculates the address of the containing object.

Parameters
objObject to calculate the containing object from
typeType of the containing object
memberMember of the containing object

◆ ctb_lengthOf

#define ctb_lengthOf ( arr)
Value:
(sizeof(arr) / sizeof(arr[0]))

Calculates the length of the given array.

Parameters
arrArray to calculate the length from

◆ ctb_obj

#define ctb_obj ( type)
Value:
((type){ 0 })

Creates an object of the given type and initializes it with zeros.

Parameters
typeType of the object

◆ ctb_staticAssert

#define ctb_staticAssert ( expression,
identifier )
Value:
typedef char identifier[(!!(expression)) * 2 - 1]

Generates a compile-time assertion.

Parameters
expressionExpression to assert
identifierIdentifier to use in the assertion