Merge branch 'sandbox' (remove finalize())
[c11tester.git] / common.h
1 /** @file common.h
2  *  @brief General purpose macros.
3  */
4
5 #ifndef __COMMON_H__
6 #define __COMMON_H__
7
8 #include <stdio.h>
9
10 /*
11 #ifndef CONFIG_DEBUG
12 #define CONFIG_DEBUG
13 #endif
14 */
15
16 #ifdef CONFIG_DEBUG
17 #define DEBUG(fmt, ...) do { printf("*** %25s(): line %-4d *** " fmt, __func__, __LINE__, ##__VA_ARGS__); } while (0)
18 #define DBG() DEBUG("\n");
19 #define DBG_ENABLED() (1)
20 #else
21 #define DEBUG(fmt, ...)
22 #define DBG()
23 #define DBG_ENABLED() (0)
24 #endif
25
26 #define ASSERT(expr) \
27 do { \
28         if (!(expr)) { \
29                 fprintf(stderr, "Error: assertion failed in %s at line %d\n", __FILE__, __LINE__); \
30                 exit(EXIT_FAILURE); \
31         } \
32 } while (0);
33
34 #endif /* __COMMON_H__ */