---
name: "Defines.h"
section: "3"
platform: "linux"
package: "libzycore-doc"
version: "1.5.2-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Defines.h"
---

# Defines.h(3)

## NAME

include/Zycore/Defines.h

## SYNOPSIS

`#include <assert.h>`\

### Macros

\#define **ZYAN\_MACRO\_CONCAT**(x,  y)   x ## y\
 \#define **ZYAN\_MACRO\_CONCAT\_EXPAND**(x,  y)   **ZYAN\_MACRO\_CONCAT**(x, y)\
 \#define **ZYAN\_UNKNOWN\_COMPILER**\
 \#define **ZYAN\_UNKNOWN\_PLATFORM**\
 \#define **ZYAN\_USER**\
 \#define **ZYAN\_RELEASE**\
 \#define **ZYAN\_DEPRECATED**\
 \#define **ZYAN\_DLLEXPORT**\
 \#define **ZYAN\_DLLIMPORT**\
 \#define **ZYCORE\_EXPORT**   ZYAN\_DLLIMPORT\
 \#define **ZYCORE\_NO\_EXPORT**\
 \#define **ZYAN\_NO\_SANITIZE**(what)\
 \#define **ZYAN\_INLINE**   static inline\
 \#define **ZYAN\_NOINLINE**\
 \#define **ZYAN\_ASSERT**(condition)   assert(condition)\
 \#define **ZYAN\_STATIC\_ASSERT**(x)           typedef int **ZYAN\_MACRO\_CONCAT\_EXPAND**(ZYAN\_SASSERT\_, \_\_COUNTER\_\_) \[(x) ? 1 : -1\]\
 \#define **ZYAN\_UNREACHABLE**   for(;;)\
 \#define **ZYAN\_UNUSED**(x)   (void)(x)\
 \#define **ZYAN\_FALLTHROUGH**\
 \#define **ZYAN\_BITFIELD**(x)   : x\
 \#define **ZYAN\_REQUIRES\_LIBC**\
 \#define **ZYAN\_PRINTF\_ATTR**(format\_index,  first\_to\_check)\
 \#define **ZYAN\_WPRINTF\_ATTR**(format\_index,  first\_to\_check)\
 \#define **ZYAN\_ARRAY\_LENGTH**(a)   (sizeof(a) / sizeof((a)\[0\]))\
 \#define **ZYAN\_MIN**(a,  b)   (((a) \< (b)) ? (a) : (b))\
 \#define **ZYAN\_MAX**(a,  b)   (((a) \> (b)) ? (a) : (b))\
 \#define **ZYAN\_ABS**(a)   (((a) \< 0) ? -(a) : (a))\
 \#define **ZYAN\_IS\_POWER\_OF\_2**(x)   (((x) & ((x) - 1)) == 0)\
 \#define **ZYAN\_IS\_ALIGNED\_TO**(x,  align)   (((x) & ((align) - 1)) == 0)\
 \#define **ZYAN\_ALIGN\_UP**(x,  align)   (((x) + (align) - 1) & ~((align) - 1))\
 \#define **ZYAN\_ALIGN\_DOWN**(x,  align)   (((x) - 1) & ~((align) - 1))\
 \#define **ZYAN\_DIV64**(n,  divisor)   (n /= divisor)\
 \#define **ZYAN\_NEEDS\_BIT**(n,  b)   (((unsigned long)(n) \>\> (b)) \> 0)\
 \#define **ZYAN\_BITS\_TO\_REPRESENT**(n)\

## Detailed Description

General helper and platform detection macros.

## Macro Definition Documentation

### #define ZYAN\_ABS(a) (((a) \< 0) ? -(a) : (a))

Returns the absolute value of `a`.

**Parameters**

*a* The value.

**Returns**

The absolute value of `a`.

### #define ZYAN\_ALIGN\_DOWN(x, align) (((x) - 1) & ~((align) - 1))

Aligns the value to the nearest given alignment boundary (by rounding it down).

**Parameters**

*x* The value. \
 *align* The desired alignment.

**Returns**

The aligned value.

Note that this macro only works for powers of 2.

### #define ZYAN\_ALIGN\_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))

Aligns the value to the nearest given alignment boundary (by rounding it up).

**Parameters**

*x* The value. \
 *align* The desired alignment.

**Returns**

The aligned value.

Note that this macro only works for powers of 2.

### #define ZYAN\_ARRAY\_LENGTH(a) (sizeof(a) / sizeof((a)\[0\]))

Returns the length (number of elements) of an array.

**Parameters**

*a* The name of the array.

**Returns**

The number of elements of the given array.

### #define ZYAN\_ASSERT(condition) assert(condition)

Runtime debug assertion.

### #define ZYAN\_BITFIELD(x) : x

Declares a bitfield.

**Parameters**

*x* The size (in bits) of the bitfield.

### #define ZYAN\_BITS\_TO\_REPRESENT(n)

**Value:**.PP

```
    ( \
        ZYAN_NEEDS_BIT(n,  0) + ZYAN_NEEDS_BIT(n,  1) + \
        ZYAN_NEEDS_BIT(n,  2) + ZYAN_NEEDS_BIT(n,  3) + \
        ZYAN_NEEDS_BIT(n,  4) + ZYAN_NEEDS_BIT(n,  5) + \
        ZYAN_NEEDS_BIT(n,  6) + ZYAN_NEEDS_BIT(n,  7) + \
        ZYAN_NEEDS_BIT(n,  8) + ZYAN_NEEDS_BIT(n,  9) + \
        ZYAN_NEEDS_BIT(n, 10) + ZYAN_NEEDS_BIT(n, 11) + \
        ZYAN_NEEDS_BIT(n, 12) + ZYAN_NEEDS_BIT(n, 13) + \
        ZYAN_NEEDS_BIT(n, 14) + ZYAN_NEEDS_BIT(n, 15) + \
        ZYAN_NEEDS_BIT(n, 16) + ZYAN_NEEDS_BIT(n, 17) + \
        ZYAN_NEEDS_BIT(n, 18) + ZYAN_NEEDS_BIT(n, 19) + \
        ZYAN_NEEDS_BIT(n, 20) + ZYAN_NEEDS_BIT(n, 21) + \
        ZYAN_NEEDS_BIT(n, 22) + ZYAN_NEEDS_BIT(n, 23) + \
        ZYAN_NEEDS_BIT(n, 24) + ZYAN_NEEDS_BIT(n, 25) + \
        ZYAN_NEEDS_BIT(n, 26) + ZYAN_NEEDS_BIT(n, 27) + \
        ZYAN_NEEDS_BIT(n, 28) + ZYAN_NEEDS_BIT(n, 29) + \
        ZYAN_NEEDS_BIT(n, 30) + ZYAN_NEEDS_BIT(n, 31)   \
    )
```

### #define ZYAN\_DIV64(n, divisor) (n /= divisor)

Divide the 64bit integer value by the given divisor.

**Parameters**

*n* Variable containing the dividend that will be updated with the result of the division. \
 *divisor* The divisor.

### #define ZYAN\_FALLTHROUGH

Intentional fallthrough.

### #define ZYAN\_IS\_ALIGNED\_TO(x, align) (((x) & ((align) - 1)) == 0)

Checks, if the given value is properly aligned.

Note that this macro only works for powers of 2.

### #define ZYAN\_IS\_POWER\_OF\_2(x) (((x) & ((x) - 1)) == 0)

Checks, if the given value is a power of 2.

**Parameters**

*x* The value.

**Returns**

`ZYAN_TRUE`, if the given value is a power of 2 or `ZYAN_FALSE`, if not.

Note that this macro always returns `ZYAN_TRUE` for `x == 0`.

### #define ZYAN\_MACRO\_CONCAT(x, y) x ## y

Concatenates two values using the stringify operator (`##`).

**Parameters**

*x* The first value. \
 *y* The second value.

**Returns**

The combined string of the given values.

### #define ZYAN\_MACRO\_CONCAT\_EXPAND(x, y) ZYAN\_MACRO\_CONCAT(x, y)

Concatenates two values using the stringify operator (`##`) and expands the value to be used in another macro.

**Parameters**

*x* The first value. \
 *y* The second value.

**Returns**

The combined string of the given values.

### #define ZYAN\_MAX(a, b) (((a) \> (b)) ? (a) : (b))

Returns the bigger value of `a` or `b`.

**Parameters**

*a* The first value. \
 *b* The second value.

**Returns**

The bigger value of `a` or `b`.

### #define ZYAN\_MIN(a, b) (((a) \< (b)) ? (a) : (b))

Returns the smaller value of `a` or `b`.

**Parameters**

*a* The first value. \
 *b* The second value.

**Returns**

The smaller value of `a` or `b`.

### #define ZYAN\_PRINTF\_ATTR(format\_index, first\_to\_check)

Decorator for `printf`-style functions.

**Parameters**

*format\_index* The 1-based index of the format string parameter. \
 *first\_to\_check* The 1-based index of the format arguments parameter.

### #define ZYAN\_REQUIRES\_LIBC

Marks functions that require libc (cannot be used with `ZYAN_NO_LIBC`).

### #define ZYAN\_STATIC\_ASSERT(x) typedef int ZYAN\_MACRO\_CONCAT\_EXPAND(ZYAN\_SASSERT\_, \_\_COUNTER\_\_) \[(x) ? 1 : -1\]

Compiler-time assertion.

### #define ZYAN\_UNREACHABLE for(;;)

Marks the current code path as unreachable.

### #define ZYAN\_UNUSED(x) (void)(x)

Marks the specified parameter as unused.

**Parameters**

*x* The name of the unused parameter.

### #define ZYAN\_WPRINTF\_ATTR(format\_index, first\_to\_check)

Decorator for `wprintf`-style functions.

**Parameters**

*format\_index* The 1-based index of the format string parameter. \
 *first\_to\_check* The 1-based index of the format arguments parameter.

### #define ZYCORE\_EXPORT ZYAN\_DLLIMPORT

Symbol is exported in shared library builds.

### #define ZYCORE\_NO\_EXPORT

Symbol is not exported and for internal use only.

## Author

Generated automatically by Doxygen for Zycore from the source code.
