-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.h
63 lines (46 loc) · 1.74 KB
/
common.h
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
* This is mainly preprocessor macros
* which only includes some functions for logging at the momenet
*/
#pragma once
#ifndef COMMON_H
#define COMMON_H
#include <stdio.h>
// FIXME: this is only for debugging
#define DEBUG
/* extern "C" guards */
#ifdef __cplusplus
extern "C" {
#endif
/* extern "C" guards */
#ifdef __cplusplus
#define unused [[maybe_unused]]
#else
#define unused __attribute__((unused))
#endif
#define ANSI_RESET "\033[0m"
#define ANSI_GREY "\033[38;5;242m"
#define ANSI_HIGH "\033[38;5;159m"
#define ANSI_RED "\033[38;5;162m"
#define ANSI_GREEN "\033[38;5;49m"
#define ANSI_BLUE "\033[38;5;81m"
#define ANSI_ORANGE "\033[38;5;215m"
#define ANSI_YELLOW "\033[38;5;226m"
#define msg(msg, ...) printf(" " msg "\n", ##__VA_ARGS__)
#define info(msg, ...) printf(" " ANSI_GREY "[" ANSI_BLUE "*" ANSI_GREY "] " ANSI_RESET msg "\n", ##__VA_ARGS__)
#define ok(msg, ...) printf(" " ANSI_GREY "[" ANSI_GREEN "+" ANSI_GREY "] " ANSI_RESET msg "\n", ##__VA_ARGS__)
#define warn(msg, ...) printf(" " ANSI_GREY "[" ANSI_ORANGE "#" ANSI_GREY "] " ANSI_RESET msg "\n", ##__VA_ARGS__)
#define err(msg, ...) printf(" " ANSI_GREY "[" ANSI_RED "-" ANSI_GREY "] " ANSI_RESET msg "\n", ##__VA_ARGS__)
#define code_err(msg, ...) printf(" " ANSI_GREY "[" ANSI_RED "-" ANSI_GREY "] (%s:%d at %s) " ANSI_RESET msg "\n", __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__)
#ifdef DEBUG
#define dbg(msg, ...) printf(" " ANSI_GREY "[" ANSI_YELLOW "~" ANSI_GREY "] " ANSI_RESET msg "\n", ##__VA_ARGS__)
#define dbgf(msg, ...) printf(" " ANSI_GREY "[" ANSI_YELLOW "~" ANSI_GREY "] " ANSI_RESET msg, ##__VA_ARGS__)
#else
#define dbg(...)
#endif
/* extern "C" guards */
#ifdef __cplusplus
}
#endif
/* extern "C" guards */
#endif /* ifndef COMMON_H */