summaryrefslogtreecommitdiff
path: root/lr_macros.h
blob: 836ee52f86abc30ce9b7eb2e75597e63bf5a4605 (plain) (blame)
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
#ifndef LR_MACROS_H
#define LR_MACROS_H

// Detect compiler
#if __clang__

# define COMPILER_CLANG 1
#elif _MSC_VER
# define COMPILER_MSVC 1
#elif __GNUC__
# define COMPILER_GNU 1
#endif

// Zero undefined
#if !defined(COMPILER_MSVC)
# define COMPILER_MSVC 0
#endif
#if !defined(COMPILER_LLVM)
# define COMPILER_LLVM 0
#endif
#if !defined(COMPILER_GNU)
# define COMPILER_GNU 0
#endif

// Push/Pop warnings
#if COMPILER_GNU
# define PUSH_WARNINGS \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wall\"") \
_Pragma("GCC diagnostic ignored \"-Wextra\"") \
_Pragma("GCC diagnostic ignored \"-Wconversion\"")
# define POP_WARNINGS _Pragma("GCC diagnostic pop")

#elif COMPILER_CLANG
# define PUSH_WARNINGS \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Weverything\"")
# define POP_WARNINGS _Pragma("clang diagnostic pop")

#else
# error "No compatible compiler found"
#endif

#define ArrayCount(Array) (sizeof(Array) / sizeof((Array)[0]))

#define Assert(Expression) if(!(Expression)) { __asm__ volatile("int3"); }
#define DebugBreakOnce do { local_persist b32 X = false; Assert(X); X = true; } while(0)
#define NullExpression { int X = 0; }

#define Minimum(A, B) (((A) < (B)) ? (A) : (B))
#define Maximum(A, B) (((A) > (B)) ? (A) : (B))

#endif // LR_MACROS_H