Skip to content
Myr

debug.h

This file

Path

debug.h

32 lines · 945 bytes · C

Last changed by

Not known.

History of this file

Take it

1#pragma once23#include "macros.h"45#define FATAL_ERROR(...) fatal_error(__FILE__, __LINE__, __VA_ARGS__)67#ifdef NDEBUG8    #define BUG(...) UNREACHABLE()9#else10    #define BUG(...) bug(__FILE__, __LINE__, __func__, __VA_ARGS__)11#endif1213#define xassert(x) do { \14    IGNORE_WARNING("-Wtautological-compare") \15    if (unlikely(!(x))) { \16        BUG("assertion failed: '%s'", #x); \17    } \18    UNIGNORE_WARNINGS \19} while (0)2021#ifndef static_assert22    #if __STDC_VERSION__ >= 201112L23        #define static_assert(x, msg) _Static_assert((x), msg)24    #elif GNUC_AT_LEAST(4, 6) || HAS_EXTENSION(c_static_assert)25        #define static_assert(x, msg) __extension__ _Static_assert((x), msg)26    #else27        #define static_assert(x, msg)28    #endif29#endif3031noreturn void fatal_error(const char *file, int line, const char *msg, int err) COLD;32noreturn void bug(const char *file, int line, const char *func, const char *fmt, ...) PRINTF(4) COLD;