-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathkenobi.h
More file actions
48 lines (36 loc) · 1.11 KB
/
kenobi.h
File metadata and controls
48 lines (36 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
general KENOBI
General quality of life macros :)
*/
#ifndef UTILS_H_KENOBI_H
#define UTILS_H_KENOBI_H
#if defined(UTILS_H_ALL) || defined(UTILS_H_KENOBI) //Avoid defining if module was turned off
//Define types/macros here
#ifndef kenobi_perror
#include <stdio.h>
#define kenobi_perror(MSG) perror(MSG)
#endif
#ifndef kenobi_abort
#include <stdlib.h>
#define kenobi_abort() abort()
#endif
#define kenobi_new_struct(NAME, ...) typedef struct NAME{ \
__VA_ARGS__ \
}NAME
#define kenobi_new_struct_free(NAME, ...) kenobi_new_struct(NAME, __VA_ARGS__); \
void NAME##_free(NAME)
#define kenobi_new_enum(NAME, ...) typedef enum NAME{ \
__VA_ARGS__ \
}NAME
void kenobi_panic(const char* MSG);
//end of types
#if defined(UTILS_H_IMPLEMENTATION) || defined(UTILS_H_KENOBI_IMPLEMENTATION) //Implementation part only gets compiled once
//Declare variables here
void kenobi_panic(const char* MSG) {
kenobi_perror(MSG);
kenobi_abort();
}
//end of variables
#endif //UTILS_H_KENOBI_IMPLEMENTATION
#endif //UTILS_H_ALL || UTILS_H_KENOBI
#endif //UTILS_H_KENOBI_H