genclibs/runtime_assert.h
2024-10-14 15:26:57 +02:00

15 lines
418 B
C

#ifndef RUNTIME_ASSERT_H
#define RUNTIME_ASSERT_H
#include <assert.h>
#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#define runtime_assert(x, ...) for (bool expression = x; !(expression); assert(expression && # x)) __VA_OPT__(fprintf(stderr, __VA_ARGS__), fprintf(stderr, " (errno : %s)", (errno == 0) ? "OK" : strerror(errno)), fprintf(stderr, "\n"))
#endif //RUNTIME_ASSERT_H