| |
1 /* |
| |
2 * LDForge: LDraw parts authoring CAD |
| |
3 * Copyright (C) 2013 Santeri Piippo |
| |
4 * |
| |
5 * This program is free software: you can redistribute it and/or modify |
| |
6 * it under the terms of the GNU General Public License as published by |
| |
7 * the Free Software Foundation, either version 3 of the License, or |
| |
8 * (at your option) any later version. |
| |
9 * |
| |
10 * This program is distributed in the hope that it will be useful, |
| |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| |
13 * GNU General Public License for more details. |
| |
14 * |
| |
15 * You should have received a copy of the GNU General Public License |
| |
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| |
17 */ |
| |
18 |
| |
19 // ============================================================================= |
| |
20 // This file is included one way or another in every source file of LDForge. |
| |
21 // Stuff defined and included here is universally included. |
| |
22 |
| |
23 #ifndef LDFORGE_MAIN_H |
| |
24 #define LDFORGE_MAIN_H |
| |
25 |
| |
26 // Hack to make KDevelop parse QString properly. Q_REQUIRED_RESULT expands into |
| |
27 // an __attribute__((warn_unused_result)) KDevelop's lexer doesn't seem to |
| |
28 // understand, yielding an error and leaving some methods unlexed. |
| |
29 // |
| |
30 // The following first includes <QChar> to get Q_REQUIRED_RESULT defined first, |
| |
31 // then re-defining it as nothing. This causes Q_REQUIRED_RESULT to essentially |
| |
32 // "vanish" from QString's methods when KDevelop lexes them. |
| |
33 // |
| |
34 // Similar reasoning for Q_DECL_HIDDEN, except with Q_OBJECT this time. |
| |
35 #ifdef IN_IDE_PARSER |
| |
36 # include <QChar> |
| |
37 # undef Q_REQUIRED_RESULT |
| |
38 # undef Q_DECL_HIDDEN |
| |
39 # define Q_REQUIRED_RESULT |
| |
40 # define Q_DECL_HIDDEN |
| |
41 #endif |
| |
42 |
| |
43 #include <stdio.h> |
| |
44 #include <stdlib.h> |
| |
45 #include <stdint.h> |
| |
46 #include <stdarg.h> |
| |
47 #include <QString> |
| |
48 #include <QMutex> |
| |
49 |
| |
50 #include "property.h" |
| |
51 #include "config.h" |
| |
52 |
| |
53 #define APPNAME "LDForge" |
| |
54 #define UNIXNAME "ldforge" |
| |
55 #define VERSION_MAJOR 0 |
| |
56 #define VERSION_MINOR 2 |
| |
57 #define VERSION_PATCH 999 |
| |
58 #define BUILD_ID BUILD_INTERNAL |
| |
59 |
| |
60 #define BUILD_INTERNAL 0 |
| |
61 #define BUILD_ALPHA 1 |
| |
62 #define BUILD_BETA 2 |
| |
63 #define BUILD_RC 3 |
| |
64 #define BUILD_RELEASE 4 |
| |
65 |
| |
66 // RC Number for BUILD_RC |
| |
67 #define RC_NUMBER 0 |
| |
68 |
| |
69 // ============================================= |
| |
70 #ifdef DEBUG |
| |
71 # undef RELEASE |
| |
72 #endif // DEBUG |
| |
73 |
| |
74 #ifdef RELEASE |
| |
75 # undef DEBUG |
| |
76 #endif // RELEASE |
| |
77 |
| |
78 // ============================================= |
| |
79 #define alias auto& |
| |
80 #define elif(A) else if (A) |
| |
81 |
| |
82 // Null pointer |
| |
83 static const std::nullptr_t null = nullptr; |
| |
84 |
| |
85 #ifdef WIN32 |
| |
86 # define DIRSLASH "\\" |
| |
87 # define DIRSLASH_CHAR '\\' |
| |
88 #else // WIN32 |
| |
89 # define DIRSLASH "/" |
| |
90 # define DIRSLASH_CHAR '/' |
| |
91 #endif // WIN32 |
| |
92 |
| |
93 #ifdef null |
| |
94 #undef null |
| |
95 #endif // null |
| |
96 |
| |
97 #ifdef __GNUC__ |
| |
98 #define FUNCNAME __PRETTY_FUNCTION__ |
| |
99 #else |
| |
100 #define FUNCNAME __func__ |
| |
101 #endif // __GNUC__ |
| |
102 |
| |
103 // Replace assert with a version that shows a GUI dialog if possible. |
| |
104 // On Windows I just can't get the actual error messages otherwise. |
| |
105 void assertionFailure (const char* file, int line, const char* funcname, const char* expr); |
| |
106 |
| |
107 #ifdef assert |
| |
108 # undef assert |
| |
109 #endif // assert |
| |
110 |
| |
111 #ifdef DEBUG |
| |
112 # define assert(N) { ((N) ? (void) 0 : assertionFailure (__FILE__, __LINE__, FUNCNAME, #N)); } |
| |
113 #else |
| |
114 # define assert(N) {} |
| |
115 #endif // DEBUG |
| |
116 |
| |
117 // Version string identifier |
| |
118 QString versionString(); |
| |
119 QString versionMoniker(); |
| |
120 QString fullVersionString(); |
| |
121 |
| |
122 // ----------------------------------------------------------------------------- |
| |
123 #ifdef IN_IDE_PARSER // KDevelop workarounds: |
| |
124 # error IN_IDE_PARSER is defined (this code is only for KDevelop workarounds) |
| |
125 |
| |
126 # ifndef va_start |
| |
127 # define va_start(va, arg) |
| |
128 # endif // va_start |
| |
129 |
| |
130 # ifndef va_end |
| |
131 # define va_end(va) |
| |
132 # endif // va_end |
| |
133 |
| |
134 static const char* __func__ = ""; // Current function name |
| |
135 typedef void FILE; // :| |
| |
136 #endif // IN_IDE_PARSER |
| |
137 |
| |
138 #endif // LDFORGE_MAIN_H |