mirror of
https://github.com/zeldaret/oot.git
synced 2024-11-11 03:39:59 +00:00
3475651701
* libc cleanup * Suggested changes, small alloca tweak * Remove printf include
45 lines
1.1 KiB
C
45 lines
1.1 KiB
C
#ifndef ASSERT_H
|
|
#define ASSERT_H
|
|
|
|
#if !defined(__GNUC__) && !defined(__attribute__)
|
|
#define __attribute__(x)
|
|
#endif
|
|
|
|
// Runtime assertions
|
|
|
|
__attribute__((noreturn)) void __assert(const char* assertion, const char* file, int line);
|
|
|
|
// assert for matching
|
|
#ifndef NDEBUG
|
|
# ifndef NON_MATCHING
|
|
# define ASSERT(cond, msg, file, line) ((cond) ? ((void)0) : __assert(msg, file, line))
|
|
# else
|
|
# define ASSERT(cond, msg, file, line) ((cond) ? ((void)0) : __assert(#cond, __FILE__, __LINE__))
|
|
# endif
|
|
#else
|
|
# define ASSERT(cond, msg, file, line) ((void)0)
|
|
#endif
|
|
|
|
// standard assert macro
|
|
#ifndef NDEBUG
|
|
# define assert(cond) ASSERT(cond, #cond, __FILE__, __LINE__)
|
|
#else
|
|
# define assert(cond) ((void)0)
|
|
#endif
|
|
|
|
// Static/compile-time assertions
|
|
|
|
#if defined(__GNUC__) || (__STDC_VERSION__ >= 201112L)
|
|
# define static_assert(cond, msg) _Static_assert(cond, msg)
|
|
#else
|
|
# ifndef GLUE
|
|
# define GLUE(a, b) a##b
|
|
# endif
|
|
# ifndef GLUE2
|
|
# define GLUE2(a, b) GLUE(a, b)
|
|
# endif
|
|
|
|
# define static_assert(cond, msg) typedef char GLUE2(static_assertion_failed, __LINE__)[(cond) ? 1 : -1]
|
|
#endif
|
|
|
|
#endif
|