2020301918-os/inc/assert.h
2022-10-18 18:23:01 +08:00

18 lines
549 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef MINIOS_ASSERT_H
#define MINIOS_ASSERT_H
#include "stdio.h"
void _warn(const char*, int, const char*, ...);
void _panic(const char*, int, const char*, ...) __attribute__((noreturn));
#define warn(...) _warn(__FILE__, __LINE__, __VA_ARGS__)
#define panic(...) _panic(__FILE__, __LINE__, __VA_ARGS__)
#define assert(x) \
do { if (!(x)) panic("assertion failed: %s", #x); } while (0)
// 静态assert如果不符合条件就会直接在编译期报错
#define static_assert(x) switch (x) case 0: case (x):;
#endif /* MINIOS_ASSERT_H */