BlitzMax Extended  0.8.16
Pushing Blitz to the Max.
blitz_macros.h
Go to the documentation of this file.
1 
8 #ifndef BLITZ_MACROS_H
9 #define BLITZ_MACROS_H
10 
11 #ifdef __cplusplus
12 # define BB_BEGIN_DECLS extern "C" {
13 # define BB_END_DECLS }
14 #else
15 # define BB_BEGIN_DECLS
16 # define BB_END_DECLS
17 #endif
18 
19 BB_BEGIN_DECLS
20 
21 // Check OS to build for
22 
30 #ifdef __linux
31 # define BB_OS_LINUX TRUE
32 #endif
33 
39 #ifdef __APPLE__
40 # define BB_OS_MACOS TRUE
41 #endif
42 
48 #ifdef _WIN32
49 # define BB_OS_WIN32 TRUE
50 #endif
51 
52 // Check the system's CPU
53 
54 #if defined (__ppc__)
55 
60 # define BB_CPU_PPC TRUE
61 #endif
62 
63 #if defined (__i386__) || defined (_X86_)
64 
69 # define BB_CPU_X86 TRUE
70 #endif
71 
72 // Check for C version
73 
74 #if defined (__STDC_VERSION__)
75 
76 # if __STDC_VERSION__ >= 199901L
77 # define BB_ENV_C99 TRUE
78 # endif // C99
79 
80 #endif // __STDC_VERSION__
81 
82 // Check for 32/64-bit environment
83 
84 #if defined (__GNUC__)
85 
86 # if defined (__x86_64__) || __ppc64__
87 # define BB_ENV_64BIT TRUE
88 # else
89 # define BB_ENV_32BIT TRUE
90 # endif
91 
92 #elif defined (_WIN32) || defined (_WIN64)
93 
94 # if defined (_WIN64)
95 # define BB_ENV_64BIT TRUE
96 # else
97 # define BB_ENV_32BIT TRUE
98 # endif
99 
100 #endif // _WIN32 || _WIN64
101 
102 // Double-check compile-time configuration in case something went wrong
103 // on the way from blitz.bmx to gcc
104 
105 #if defined (THREADED) && !defined (BB_THREADED)
106 # define BB_THREADED TRUE
107 #endif
108 
109 #if !defined (NDEBUG) && !defined (BB_DEBUG)
110 # define BB_DEBUG TRUE
111 #endif
112 
113 // Set compile options
114 
115 #if defined (__GNUC__) && defined (BB_ENV_C99)
116 // Helpers are various (inline) functions and macros to ease development
117 # define BB_ENABLE_HELPER
118 #endif // GCC & C99
119 
120 // Error checking
121 
122 #if defined (BB_ENABLE_EXPERIMENTAL) && !defined (BB_ENV_C99)
123 # error "Experimental compilation mode requires C99."
124 #endif
125 
126 // Macros that actually do something
127 
128 #define BB_MIN(x, y) ((x) < (y) ? (x) : (y))
129 #define BB_MAX(x, y) ((x) > (y) ? (x) : (y))
130 #define BB_ABS(x) ((x) > 0 ? (x) : -(x))
131 
132 BB_END_DECLS
133 
134 #endif // BLITZ_MACROS_H