infix
A JIT-Powered FFI Library for C
Loading...
Searching...
No Matches
utility.h
Go to the documentation of this file.
1#pragma once
41#include "common/compat_c23.h"
42#include <stddef.h>
43// Check if INFIX_DEBUG_ENABLED is defined and set to a non-zero value.
44#if defined(INFIX_DEBUG_ENABLED) && INFIX_DEBUG_ENABLED
45#include <stdio.h>
53#define INFIX_DEBUG_PRINTF(...) \
54 do { \
55 printf("# INFIX_DEBUG: " __VA_ARGS__); \
56 printf("\n"); \
57 fflush(stdout); \
58 } while (0)
59
72void infix_dump_hex(const void * data, size_t size, const char * title);
81void infix_dump_state(const char * file, int line);
87#define INFIX_DUMP_STATE() infix_dump_state(__FILE__, __LINE__)
88#else // INFIX_DEBUG_ENABLED is NOT defined or is zero (Release Mode)
97#define INFIX_DEBUG_PRINTF(...) ((void)0)
112static inline void infix_dump_hex(c23_maybe_unused const void * data,
113 c23_maybe_unused size_t size,
114 c23_maybe_unused const char * title) {
115 // This function does nothing in release builds and will be optimized away entirely.
116}
130static inline void infix_dump_state(c23_maybe_unused const char * file, c23_maybe_unused int line) {
131 // This function does nothing in release builds and will be optimized away entirely.
132}
133#endif // INFIX_DEBUG_ENABLED
Provides forward compatibility macros for C23 features.
#define c23_maybe_unused
A compatibility macro for the C23 [[maybe_unused]] attribute.
Definition compat_c23.h:156
static void infix_dump_state(c23_maybe_unused const char *file, c23_maybe_unused int line)
Definition utility.h:130
static void infix_dump_hex(c23_maybe_unused const void *data, c23_maybe_unused size_t size, c23_maybe_unused const char *title)
Definition utility.h:112