scoped bindings
This commit is contained in:
parent
396716de09
commit
858f5c3eed
17 changed files with 1185 additions and 821 deletions
|
@ -23,6 +23,64 @@ do { \
|
|||
#else
|
||||
#define SPHO_STRLCPY(dst, src, len) \
|
||||
(size_t)snprintf(dst, len, "%s", src)
|
||||
#endif
|
||||
#endif /* ifdef SPHO_USE_STRLCPY */
|
||||
|
||||
#define SPHO_STRINGIFY(a) #a
|
||||
#define SPHO_MACRO_STR(b) SPHO_STRINGIFY(b)
|
||||
|
||||
#define SPHO_RIP(msg) \
|
||||
do { \
|
||||
fprintf(stderr, "SPHO_RIP(" msg ")@" \
|
||||
__FILE__ ":" __LINE__S \
|
||||
" failed. Aborting.\n"); \
|
||||
abort(); \
|
||||
} while (0)
|
||||
|
||||
|
||||
#ifdef SPHO_DEBUG
|
||||
|
||||
#define __LINE__S SPHO_MACRO_STR(__LINE__)
|
||||
|
||||
#define SPHO_PRECOND(cond) \
|
||||
do { \
|
||||
if (! (cond) ) { \
|
||||
fprintf(stderr, "SPHO_PRECOND(" #cond ")@" \
|
||||
__FILE__ ":" __LINE__S \
|
||||
" failed. Aborting.\n"); \
|
||||
abort(); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define SPHO_ASSERT(cond) \
|
||||
do { \
|
||||
if (! (cond) ) { \
|
||||
fprintf(stderr, "SPHO_ASSERT(" #cond ")@" \
|
||||
__FILE__ ":" __LINE__S \
|
||||
" failed. Aborting.\n"); \
|
||||
abort(); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define SPHO_POSTCOND(cond) \
|
||||
do { \
|
||||
if (! (cond) ) { \
|
||||
fprintf(stderr, "SPHO_POSTCOND(" #cond ")@" \
|
||||
__FILE__ ":" __LINE__S \
|
||||
" failed. Aborting.\n"); \
|
||||
abort(); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
#ifdef SPHO_ENABLE_DEBUG_PRINT
|
||||
#define SPHO_DEBUG_PRINT(fmt, ...) \
|
||||
do { \
|
||||
fprintf(stderr, fmt __VA_OPT__(,) __VA_ARGS__); \
|
||||
} while (0)
|
||||
#else
|
||||
#define SPHO_DEBUG_PRINT(fmt, ...)
|
||||
#endif /* ifdef SPHO_ENABLE_DEBUG_PRINT */
|
||||
|
||||
#endif /* ifdef SPHO_DEBUG */
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue