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// The double_tap framework is only included if both debug mode AND the main
46// test harness toggle are enabled. This allows for debug builds of non-test executables.
47#if defined(DBLTAP_ENABLE)
48#include "common/double_tap.h"
61#define INFIX_DEBUG_PRINTF(...) note("INFIX_DEBUG: " __VA_ARGS__)
62#else
63#include <stdio.h>
72#define INFIX_DEBUG_PRINTF(...) \
73 do { \
74 printf("# INFIX_DEBUG: " __VA_ARGS__); \
75 printf("\n"); \
76 fflush(stdout); \
77 } while (0)
78#endif // DBLTAP_ENABLE
91void infix_dump_hex(const void * data, size_t size, const char * title);
100void infix_dump_state(const char * file, int line);
106#define INFIX_DUMP_STATE() infix_dump_state(__FILE__, __LINE__)
107#else // INFIX_DEBUG_ENABLED is NOT defined or is zero (Release Mode)
116#define INFIX_DEBUG_PRINTF(...) ((void)0)
131static inline void infix_dump_hex(c23_maybe_unused const void * data,
132 c23_maybe_unused size_t size,
133 c23_maybe_unused const char * title) {
134 // This function does nothing in release builds and will be optimized away entirely.
135}
149static inline void infix_dump_state(c23_maybe_unused const char * file, c23_maybe_unused int line) {
150 // This function does nothing in release builds and will be optimized away entirely.
151}
152#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:155
A lightweight, single-header TAP (Test Anything Protocol) library.
static void infix_dump_state(c23_maybe_unused const char *file, c23_maybe_unused int line)
Definition utility.h:149
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:131