helper.h (1159B)
1 /* `helper.h` -> Helper macros/functions 2 */ 3 4 #ifndef HELPER_H 5 #define HELPER_H 6 7 #include <stdio.h> 8 9 #define ASSERT(condition, message)\ 10 if (!(condition)) \ 11 { \ 12 fprintf(stderr, message); \ 13 exit(1); \ 14 } 15 16 #define SIZE_ASSERT(condition) \ 17 if (!(condition)) \ 18 { \ 19 fprintf(stderr, "address exeeded namespace limit\n"); \ 20 exit(1); \ 21 } 22 23 #define M_ASSERT(x) \ 24 if (x == NULL) \ 25 { \ 26 fprintf(stderr, "Could not allocate memory\n");\ 27 exit(1); \ 28 } 29 30 #define N_ASSERT(x, id) \ 31 if (x == NULL) \ 32 { \ 33 fprintf(stderr, "Null Exception\n");\ 34 fprintf(stderr, id); \ 35 exit(1); \ 36 } \ 37 38 #endif // HELPER_H