src/common.h

changeset 497
c51941e590b6
parent 493
16766ac1bbd9
child 498
791c831c8020
equal deleted inserted replaced
496:d6cbf21af8fb 497:c51941e590b6
18 18
19 // ============================================================================= 19 // =============================================================================
20 // This file is included one way or another in every source file of LDForge. 20 // This file is included one way or another in every source file of LDForge.
21 // Stuff defined and included here is universally included. 21 // Stuff defined and included here is universally included.
22 22
23 #ifndef COMMON_H 23 #ifndef LDFORGE_COMMON_H
24 #define COMMON_H 24 #define LDFORGE_COMMON_H
25 25
26 #include <stdio.h> 26 #include <stdio.h>
27 #include <stdlib.h> 27 #include <stdlib.h>
28 #include <assert.h> 28 #include <assert.h>
29 #include <stdint.h> 29 #include <stdint.h>
66 # define FORMAT_PRINTF(M,N) 66 # define FORMAT_PRINTF(M,N)
67 # define ATTR(N) 67 # define ATTR(N)
68 #endif // __GNUC__ 68 #endif // __GNUC__
69 69
70 #ifdef WIN32 70 #ifdef WIN32
71 #define DIRSLASH "\\" 71 # define DIRSLASH "\\"
72 #define DIRSLASH_CHAR '\\' 72 # define DIRSLASH_CHAR '\\'
73 #else // WIN32 73 #else // WIN32
74 #define DIRSLASH "/" 74 # define DIRSLASH "/"
75 #define DIRSLASH_CHAR '/' 75 # define DIRSLASH_CHAR '/'
76 #endif // WIN32 76 #endif // WIN32
77 77
78 #ifdef RELEASE 78 #ifdef RELEASE
79 #define NDEBUG // remove asserts 79 # define NDEBUG // remove asserts
80 #endif // RELEASE 80 #endif // RELEASE
81 81
82 #define PROP_NAME(GET) m_##GET 82 #define PROP_NAME(GET) m_##GET
83 83
84 #define READ_ACCESSOR(T, GET) \ 84 #define READ_ACCESSOR(T, GET) \
140 #define FUNCNAME __PRETTY_FUNCTION__ 140 #define FUNCNAME __PRETTY_FUNCTION__
141 #else 141 #else
142 #define FUNCNAME __func__ 142 #define FUNCNAME __func__
143 #endif // __GNUC__ 143 #endif // __GNUC__
144 144
145 // Replace assert with a version that shows a GUI dialog if possible 145 // Replace assert with a version that shows a GUI dialog if possible.
146 // On Windows I just can't get the actual error messages otherwise.
146 #ifdef assert 147 #ifdef assert
147 #undef assert 148 #undef assert
148 #endif // assert 149 #endif // assert
149 150
150 class QString;
151 typedef QString str;
152
153 void assertionFailure (const char* file, const ulong line, const char* funcname, const char* expr); 151 void assertionFailure (const char* file, const ulong line, const char* funcname, const char* expr);
154 void fatalError (const char* file, const ulong line, const char* funcname, str errmsg); 152 #define assert(N) ((N) ? (void) 0 : assertionFailure (__FILE__, __LINE__, FUNCNAME, #N))
155 153
156 // Version string identifier 154 // Version string identifier
157 str versionString(); 155 QString versionString();
158 str versionMoniker(); 156 QString versionMoniker();
159 str fullVersionString(); 157 QString fullVersionString();
160
161 #define assert(N) \
162 ((N) ? (void) 0 : assertionFailure (__FILE__, __LINE__, FUNCNAME, #N))
163
164 #define fatal(MSG) \
165 fatalError (__FILE__, __LINE__, FUNCNAME, MSG)
166 158
167 // ----------------------------------------------------------------------------- 159 // -----------------------------------------------------------------------------
168 #ifdef IN_IDE_PARSER // KDevelop workarounds: 160 #ifdef IN_IDE_PARSER // KDevelop workarounds:
169 # error IN_IDE_PARSER is defined (this code is only for KDevelop workarounds) 161 # error IN_IDE_PARSER is defined (this code is only for KDevelop workarounds)
170 162
178 170
179 static const char* __func__ = ""; // Current function name 171 static const char* __func__ = ""; // Current function name
180 typedef void FILE; // :| 172 typedef void FILE; // :|
181 #endif // IN_IDE_PARSER 173 #endif // IN_IDE_PARSER
182 174
183 #endif // COMMON_H 175 #endif // LDFORGE_COMMON_H

mercurial