Mercurial > hg > openttd
annotate src/stdafx.h @ 20699:d198fbc52efc draft
-Fix: [Win32] The console code page for non-Unicode builds is not the normal ANSI code page and definitely not UTF-8 either.
author | Michael Lutz <michi@icosahedron.de> |
---|---|
date | Thu, 28 Mar 2013 02:41:43 +0100 (2013-03-28) |
parents | 90e3d5cae92a |
children | 4708d25893c5 |
rev | line source |
---|---|
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
1 /* $Id$ */ |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
2 |
12778
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12753
diff
changeset
|
3 /* |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12753
diff
changeset
|
4 * This file is part of OpenTTD. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12753
diff
changeset
|
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12753
diff
changeset
|
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12753
diff
changeset
|
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12753
diff
changeset
|
8 */ |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12753
diff
changeset
|
9 |
9111
d48433370037
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium <rubidium@openttd.org>
parents:
9072
diff
changeset
|
10 /** @file stdafx.h Definition of base types and functions in a cross-platform compatible way. */ |
6420
080aae477331
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas <belugas@openttd.org>
parents:
6285
diff
changeset
|
11 |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
12 #ifndef STDAFX_H |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
13 #define STDAFX_H |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
14 |
11531
23734bd05e51
(svn r15892) -Codechange: [OSX] some type fixes so OpenTTD likes more of the 3.1.x Xcodes.
rubidium <rubidium@openttd.org>
parents:
11360
diff
changeset
|
15 #if defined(__APPLE__) |
23734bd05e51
(svn r15892) -Codechange: [OSX] some type fixes so OpenTTD likes more of the 3.1.x Xcodes.
rubidium <rubidium@openttd.org>
parents:
11360
diff
changeset
|
16 #include "os/macosx/osx_stdafx.h" |
23734bd05e51
(svn r15892) -Codechange: [OSX] some type fixes so OpenTTD likes more of the 3.1.x Xcodes.
rubidium <rubidium@openttd.org>
parents:
11360
diff
changeset
|
17 #endif /* __APPLE__ */ |
23734bd05e51
(svn r15892) -Codechange: [OSX] some type fixes so OpenTTD likes more of the 3.1.x Xcodes.
rubidium <rubidium@openttd.org>
parents:
11360
diff
changeset
|
18 |
13105
e1e6490148f5
(svn r17606) -Add: initial support for Haiku; a dedicated server with zlib and libpng compiles and links (for me). Something's fishy with the network so it doesn't actually work (yet)
rubidium <rubidium@openttd.org>
parents:
12971
diff
changeset
|
19 #if defined(__BEOS__) || defined(__HAIKU__) |
e1e6490148f5
(svn r17606) -Add: initial support for Haiku; a dedicated server with zlib and libpng compiles and links (for me). Something's fishy with the network so it doesn't actually work (yet)
rubidium <rubidium@openttd.org>
parents:
12971
diff
changeset
|
20 #include <SupportDefs.h> |
e1e6490148f5
(svn r17606) -Add: initial support for Haiku; a dedicated server with zlib and libpng compiles and links (for me). Something's fishy with the network so it doesn't actually work (yet)
rubidium <rubidium@openttd.org>
parents:
12971
diff
changeset
|
21 #include <unistd.h> |
e1e6490148f5
(svn r17606) -Add: initial support for Haiku; a dedicated server with zlib and libpng compiles and links (for me). Something's fishy with the network so it doesn't actually work (yet)
rubidium <rubidium@openttd.org>
parents:
12971
diff
changeset
|
22 #define _GNU_SOURCE |
e1e6490148f5
(svn r17606) -Add: initial support for Haiku; a dedicated server with zlib and libpng compiles and links (for me). Something's fishy with the network so it doesn't actually work (yet)
rubidium <rubidium@openttd.org>
parents:
12971
diff
changeset
|
23 #define TROUBLED_INTS |
e1e6490148f5
(svn r17606) -Add: initial support for Haiku; a dedicated server with zlib and libpng compiles and links (for me). Something's fishy with the network so it doesn't actually work (yet)
rubidium <rubidium@openttd.org>
parents:
12971
diff
changeset
|
24 #elif defined(__NDS__) |
8373
a6209668c216
(svn r11939) -Codechange: some type fixes and very initial steps into supporting NDS by default. Based on work by Dominik.
rubidium <rubidium@openttd.org>
parents:
8292
diff
changeset
|
25 #include <nds/jtypes.h> |
13105
e1e6490148f5
(svn r17606) -Add: initial support for Haiku; a dedicated server with zlib and libpng compiles and links (for me). Something's fishy with the network so it doesn't actually work (yet)
rubidium <rubidium@openttd.org>
parents:
12971
diff
changeset
|
26 #define TROUBLED_INTS |
e1e6490148f5
(svn r17606) -Add: initial support for Haiku; a dedicated server with zlib and libpng compiles and links (for me). Something's fishy with the network so it doesn't actually work (yet)
rubidium <rubidium@openttd.org>
parents:
12971
diff
changeset
|
27 #endif |
8373
a6209668c216
(svn r11939) -Codechange: some type fixes and very initial steps into supporting NDS by default. Based on work by Dominik.
rubidium <rubidium@openttd.org>
parents:
8292
diff
changeset
|
28 |
5820
f2218210a022
(svn r8382) -Fix (r8374): moved the include of stdint.h to the front of stdafx.h
bjarni <bjarni@openttd.org>
parents:
5812
diff
changeset
|
29 /* It seems that we need to include stdint.h before anything else |
f2218210a022
(svn r8382) -Fix (r8374): moved the include of stdint.h to the front of stdafx.h
bjarni <bjarni@openttd.org>
parents:
5812
diff
changeset
|
30 * We need INT64_MAX, which for most systems comes from stdint.h. However, MSVC |
19994
f2bda548c536
(svn r24926) -Fix [FS#5373]: Check integer min/max macros individually, and define them if missing.
frosch <frosch@openttd.org>
parents:
19849
diff
changeset
|
31 * does not have stdint.h and apparently neither does MorphOS. |
f2bda548c536
(svn r24926) -Fix [FS#5373]: Check integer min/max macros individually, and define them if missing.
frosch <frosch@openttd.org>
parents:
19849
diff
changeset
|
32 * For OSX the inclusion is already done in osx_stdafx.h. */ |
20179
90e3d5cae92a
(svn r25128) -Codechange: [Win32] MSVC 2010 comes with stdint.h.
michi_cc <michi_cc@openttd.org>
parents:
19994
diff
changeset
|
33 #if !defined(__APPLE__) && (!defined(_MSC_VER) || _MSC_VER >= 1600) && !defined(__MORPHOS__) |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
34 #if defined(SUNOS) |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
35 /* SunOS/Solaris does not have stdint.h, but inttypes.h defines everything |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
36 * stdint.h defines and we need. */ |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
37 #include <inttypes.h> |
19994
f2bda548c536
(svn r24926) -Fix [FS#5373]: Check integer min/max macros individually, and define them if missing.
frosch <frosch@openttd.org>
parents:
19849
diff
changeset
|
38 #else |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
39 #define __STDC_LIMIT_MACROS |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
40 #include <stdint.h> |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
41 #endif |
19994
f2bda548c536
(svn r24926) -Fix [FS#5373]: Check integer min/max macros individually, and define them if missing.
frosch <frosch@openttd.org>
parents:
19849
diff
changeset
|
42 #endif |
f2bda548c536
(svn r24926) -Fix [FS#5373]: Check integer min/max macros individually, and define them if missing.
frosch <frosch@openttd.org>
parents:
19849
diff
changeset
|
43 |
f2bda548c536
(svn r24926) -Fix [FS#5373]: Check integer min/max macros individually, and define them if missing.
frosch <frosch@openttd.org>
parents:
19849
diff
changeset
|
44 /* The conditions for these constants to be available are way too messy; so check them one by one */ |
f2bda548c536
(svn r24926) -Fix [FS#5373]: Check integer min/max macros individually, and define them if missing.
frosch <frosch@openttd.org>
parents:
19849
diff
changeset
|
45 #if !defined(UINT64_MAX) |
8825
1603ed357fcb
(svn r12573) -Codechange: use defined constants instead of numbers in math_func.hpp
smatz <smatz@openttd.org>
parents:
8823
diff
changeset
|
46 #define UINT64_MAX (18446744073709551615ULL) |
19994
f2bda548c536
(svn r24926) -Fix [FS#5373]: Check integer min/max macros individually, and define them if missing.
frosch <frosch@openttd.org>
parents:
19849
diff
changeset
|
47 #endif |
f2bda548c536
(svn r24926) -Fix [FS#5373]: Check integer min/max macros individually, and define them if missing.
frosch <frosch@openttd.org>
parents:
19849
diff
changeset
|
48 #if !defined(INT64_MAX) |
8825
1603ed357fcb
(svn r12573) -Codechange: use defined constants instead of numbers in math_func.hpp
smatz <smatz@openttd.org>
parents:
8823
diff
changeset
|
49 #define INT64_MAX (9223372036854775807LL) |
19994
f2bda548c536
(svn r24926) -Fix [FS#5373]: Check integer min/max macros individually, and define them if missing.
frosch <frosch@openttd.org>
parents:
19849
diff
changeset
|
50 #endif |
f2bda548c536
(svn r24926) -Fix [FS#5373]: Check integer min/max macros individually, and define them if missing.
frosch <frosch@openttd.org>
parents:
19849
diff
changeset
|
51 #if !defined(INT64_MIN) |
8825
1603ed357fcb
(svn r12573) -Codechange: use defined constants instead of numbers in math_func.hpp
smatz <smatz@openttd.org>
parents:
8823
diff
changeset
|
52 #define INT64_MIN (-INT64_MAX - 1) |
19994
f2bda548c536
(svn r24926) -Fix [FS#5373]: Check integer min/max macros individually, and define them if missing.
frosch <frosch@openttd.org>
parents:
19849
diff
changeset
|
53 #endif |
f2bda548c536
(svn r24926) -Fix [FS#5373]: Check integer min/max macros individually, and define them if missing.
frosch <frosch@openttd.org>
parents:
19849
diff
changeset
|
54 #if !defined(UINT32_MAX) |
8825
1603ed357fcb
(svn r12573) -Codechange: use defined constants instead of numbers in math_func.hpp
smatz <smatz@openttd.org>
parents:
8823
diff
changeset
|
55 #define UINT32_MAX (4294967295U) |
19994
f2bda548c536
(svn r24926) -Fix [FS#5373]: Check integer min/max macros individually, and define them if missing.
frosch <frosch@openttd.org>
parents:
19849
diff
changeset
|
56 #endif |
f2bda548c536
(svn r24926) -Fix [FS#5373]: Check integer min/max macros individually, and define them if missing.
frosch <frosch@openttd.org>
parents:
19849
diff
changeset
|
57 #if !defined(INT32_MAX) |
8825
1603ed357fcb
(svn r12573) -Codechange: use defined constants instead of numbers in math_func.hpp
smatz <smatz@openttd.org>
parents:
8823
diff
changeset
|
58 #define INT32_MAX (2147483647) |
19994
f2bda548c536
(svn r24926) -Fix [FS#5373]: Check integer min/max macros individually, and define them if missing.
frosch <frosch@openttd.org>
parents:
19849
diff
changeset
|
59 #endif |
f2bda548c536
(svn r24926) -Fix [FS#5373]: Check integer min/max macros individually, and define them if missing.
frosch <frosch@openttd.org>
parents:
19849
diff
changeset
|
60 #if !defined(INT32_MIN) |
8825
1603ed357fcb
(svn r12573) -Codechange: use defined constants instead of numbers in math_func.hpp
smatz <smatz@openttd.org>
parents:
8823
diff
changeset
|
61 #define INT32_MIN (-INT32_MAX - 1) |
19994
f2bda548c536
(svn r24926) -Fix [FS#5373]: Check integer min/max macros individually, and define them if missing.
frosch <frosch@openttd.org>
parents:
19849
diff
changeset
|
62 #endif |
f2bda548c536
(svn r24926) -Fix [FS#5373]: Check integer min/max macros individually, and define them if missing.
frosch <frosch@openttd.org>
parents:
19849
diff
changeset
|
63 #if !defined(UINT16_MAX) |
8825
1603ed357fcb
(svn r12573) -Codechange: use defined constants instead of numbers in math_func.hpp
smatz <smatz@openttd.org>
parents:
8823
diff
changeset
|
64 #define UINT16_MAX (65535U) |
19994
f2bda548c536
(svn r24926) -Fix [FS#5373]: Check integer min/max macros individually, and define them if missing.
frosch <frosch@openttd.org>
parents:
19849
diff
changeset
|
65 #endif |
f2bda548c536
(svn r24926) -Fix [FS#5373]: Check integer min/max macros individually, and define them if missing.
frosch <frosch@openttd.org>
parents:
19849
diff
changeset
|
66 #if !defined(INT16_MAX) |
8825
1603ed357fcb
(svn r12573) -Codechange: use defined constants instead of numbers in math_func.hpp
smatz <smatz@openttd.org>
parents:
8823
diff
changeset
|
67 #define INT16_MAX (32767) |
19994
f2bda548c536
(svn r24926) -Fix [FS#5373]: Check integer min/max macros individually, and define them if missing.
frosch <frosch@openttd.org>
parents:
19849
diff
changeset
|
68 #endif |
f2bda548c536
(svn r24926) -Fix [FS#5373]: Check integer min/max macros individually, and define them if missing.
frosch <frosch@openttd.org>
parents:
19849
diff
changeset
|
69 #if !defined(INT16_MIN) |
8825
1603ed357fcb
(svn r12573) -Codechange: use defined constants instead of numbers in math_func.hpp
smatz <smatz@openttd.org>
parents:
8823
diff
changeset
|
70 #define INT16_MIN (-INT16_MAX - 1) |
19994
f2bda548c536
(svn r24926) -Fix [FS#5373]: Check integer min/max macros individually, and define them if missing.
frosch <frosch@openttd.org>
parents:
19849
diff
changeset
|
71 #endif |
f2bda548c536
(svn r24926) -Fix [FS#5373]: Check integer min/max macros individually, and define them if missing.
frosch <frosch@openttd.org>
parents:
19849
diff
changeset
|
72 #if !defined(UINT8_MAX) |
14600
9a56ed7a8be0
(svn r19177) -Codechange: introduce INT8_MIN/MAX and UINT8_MAX for MSVC.
rubidium <rubidium@openttd.org>
parents:
14310
diff
changeset
|
73 #define UINT8_MAX (255) |
19994
f2bda548c536
(svn r24926) -Fix [FS#5373]: Check integer min/max macros individually, and define them if missing.
frosch <frosch@openttd.org>
parents:
19849
diff
changeset
|
74 #endif |
f2bda548c536
(svn r24926) -Fix [FS#5373]: Check integer min/max macros individually, and define them if missing.
frosch <frosch@openttd.org>
parents:
19849
diff
changeset
|
75 #if !defined(INT8_MAX) |
14600
9a56ed7a8be0
(svn r19177) -Codechange: introduce INT8_MIN/MAX and UINT8_MAX for MSVC.
rubidium <rubidium@openttd.org>
parents:
14310
diff
changeset
|
76 #define INT8_MAX (127) |
19994
f2bda548c536
(svn r24926) -Fix [FS#5373]: Check integer min/max macros individually, and define them if missing.
frosch <frosch@openttd.org>
parents:
19849
diff
changeset
|
77 #endif |
f2bda548c536
(svn r24926) -Fix [FS#5373]: Check integer min/max macros individually, and define them if missing.
frosch <frosch@openttd.org>
parents:
19849
diff
changeset
|
78 #if !defined(INT8_MIN) |
14600
9a56ed7a8be0
(svn r19177) -Codechange: introduce INT8_MIN/MAX and UINT8_MAX for MSVC.
rubidium <rubidium@openttd.org>
parents:
14310
diff
changeset
|
79 #define INT8_MIN (-INT8_MAX - 1) |
5820
f2218210a022
(svn r8382) -Fix (r8374): moved the include of stdint.h to the front of stdafx.h
bjarni <bjarni@openttd.org>
parents:
5812
diff
changeset
|
80 #endif |
f2218210a022
(svn r8382) -Fix (r8374): moved the include of stdint.h to the front of stdafx.h
bjarni <bjarni@openttd.org>
parents:
5812
diff
changeset
|
81 |
5933
ee0256366578
(svn r8572) -Fix: use the C++ version of the Standard C Library headers. This due to the fact that some stl headers will include them anyway and #undef several defines made in stdafx.h.
rubidium <rubidium@openttd.org>
parents:
5843
diff
changeset
|
82 #include <cstdio> |
ee0256366578
(svn r8572) -Fix: use the C++ version of the Standard C Library headers. This due to the fact that some stl headers will include them anyway and #undef several defines made in stdafx.h.
rubidium <rubidium@openttd.org>
parents:
5843
diff
changeset
|
83 #include <cstddef> |
ee0256366578
(svn r8572) -Fix: use the C++ version of the Standard C Library headers. This due to the fact that some stl headers will include them anyway and #undef several defines made in stdafx.h.
rubidium <rubidium@openttd.org>
parents:
5843
diff
changeset
|
84 #include <cstring> |
ee0256366578
(svn r8572) -Fix: use the C++ version of the Standard C Library headers. This due to the fact that some stl headers will include them anyway and #undef several defines made in stdafx.h.
rubidium <rubidium@openttd.org>
parents:
5843
diff
changeset
|
85 #include <cstdlib> |
ee0256366578
(svn r8572) -Fix: use the C++ version of the Standard C Library headers. This due to the fact that some stl headers will include them anyway and #undef several defines made in stdafx.h.
rubidium <rubidium@openttd.org>
parents:
5843
diff
changeset
|
86 #include <climits> |
13199
0c795d0f1cf0
(svn r17706) -Codechange: [OSX] Rework the crash handling to use the common CrashLog infrastructure.
michi_cc <michi_cc@openttd.org>
parents:
13105
diff
changeset
|
87 #include <cassert> |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
88 |
18060
26f943948e28
(svn r22875) -Codechange: Add some asserts and checks to better prevent overflow of the argument to malloc. (monoid)
michi_cc <michi_cc@openttd.org>
parents:
17421
diff
changeset
|
89 #ifndef SIZE_MAX |
26f943948e28
(svn r22875) -Codechange: Add some asserts and checks to better prevent overflow of the argument to malloc. (monoid)
michi_cc <michi_cc@openttd.org>
parents:
17421
diff
changeset
|
90 #define SIZE_MAX ((size_t)-1) |
26f943948e28
(svn r22875) -Codechange: Add some asserts and checks to better prevent overflow of the argument to malloc. (monoid)
michi_cc <michi_cc@openttd.org>
parents:
17421
diff
changeset
|
91 #endif |
26f943948e28
(svn r22875) -Codechange: Add some asserts and checks to better prevent overflow of the argument to malloc. (monoid)
michi_cc <michi_cc@openttd.org>
parents:
17421
diff
changeset
|
92 |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
93 #if defined(UNIX) || defined(__MINGW32__) |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
94 #include <sys/types.h> |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
95 #endif |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
96 |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
97 #if defined(__OS2__) |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
98 #include <types.h> |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
99 #define strcasecmp stricmp |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
100 #endif |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
101 |
5976
93a644e6044b
(svn r8674) [PSP] -Add: added network code for PSP, based on the work of Turulo
truelight <truelight@openttd.org>
parents:
5967
diff
changeset
|
102 #if defined(PSP) |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
103 #include <psptypes.h> |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
104 #include <pspdebug.h> |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
105 #include <pspthreadman.h> |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
106 #endif |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
107 |
9072
e197fbb0bbb8
(svn r12930) -Add: build support for NetBSD and HP-UX. Patch by ahoka.
rubidium <rubidium@openttd.org>
parents:
8983
diff
changeset
|
108 #if defined(SUNOS) || defined(HPUX) |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
109 #include <alloca.h> |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
110 #endif |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
111 |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
112 #if defined(__MORPHOS__) |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
113 /* MorphOS defines certain Amiga defines per default, we undefine them |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
114 * here to make the rest of source less messy and more clear what is |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
115 * required for morphos and what for AmigaOS */ |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
116 #if defined(amigaos) |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
117 #undef amigaos |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
118 #endif |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
119 #if defined(__amigaos__) |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
120 #undef __amigaos__ |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
121 # endif |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
122 #if defined(__AMIGA__) |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
123 #undef __AMIGA__ |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
124 #endif |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
125 #if defined(AMIGA) |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
126 #undef AMIGA |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
127 #endif |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
128 #if defined(amiga) |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
129 #undef amiga |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
130 #endif |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
131 /* Act like we already included this file, as it somehow gives linkage problems |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
132 * (mismatch linkage of C++ and C between this include and unistd.h). */ |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
133 #define CLIB_USERGROUP_PROTOS_H |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
134 #endif /* __MORPHOS__ */ |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
135 |
5967
0516aee3881f
(svn r8647) -Codechange: add a general way to handle platforms who can only have a limited amount of file-descripters open at any given time.
truelight <truelight@openttd.org>
parents:
5947
diff
changeset
|
136 #if defined(PSP) |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
137 /* PSP can only have 10 file-descriptors open at any given time, but this |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
138 * switch only limits reads via the Fio system. So keep 2 fds free for things |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
139 * like saving a game. */ |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
140 #define LIMITED_FDS 8 |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
141 #define printf pspDebugScreenPrintf |
5967
0516aee3881f
(svn r8647) -Codechange: add a general way to handle platforms who can only have a limited amount of file-descripters open at any given time.
truelight <truelight@openttd.org>
parents:
5947
diff
changeset
|
142 #endif /* PSP */ |
0516aee3881f
(svn r8647) -Codechange: add a general way to handle platforms who can only have a limited amount of file-descripters open at any given time.
truelight <truelight@openttd.org>
parents:
5947
diff
changeset
|
143 |
5934
3af431a1ae93
(svn r8573) -Cleanup: obey the comment style in stdafx.h.
rubidium <rubidium@openttd.org>
parents:
5933
diff
changeset
|
144 /* Stuff for GCC */ |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
145 #if defined(__GNUC__) |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
146 #define NORETURN __attribute__ ((noreturn)) |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
147 #define CDECL |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
148 #define __int64 long long |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
149 #define GCC_PACK __attribute__((packed)) |
11875
86fca539ec7a
(svn r16269) -Codechange: use gcc's ability to check parameters sent to printf-like functions
smatz <smatz@openttd.org>
parents:
11531
diff
changeset
|
150 /* Warn about functions using 'printf' format syntax. First argument determines which parameter |
86fca539ec7a
(svn r16269) -Codechange: use gcc's ability to check parameters sent to printf-like functions
smatz <smatz@openttd.org>
parents:
11531
diff
changeset
|
151 * is the format string, second argument is start of values passed to printf. */ |
86fca539ec7a
(svn r16269) -Codechange: use gcc's ability to check parameters sent to printf-like functions
smatz <smatz@openttd.org>
parents:
11531
diff
changeset
|
152 #define WARN_FORMAT(string, args) __attribute__ ((format (printf, string, args))) |
18740
3dcacc91f96f
(svn r23588) -Codechange: use the 'final' keyword so compiler can optimise out some indirect calls
smatz <smatz@openttd.org>
parents:
18362
diff
changeset
|
153 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) |
3dcacc91f96f
(svn r23588) -Codechange: use the 'final' keyword so compiler can optimise out some indirect calls
smatz <smatz@openttd.org>
parents:
18362
diff
changeset
|
154 #define FINAL final |
3dcacc91f96f
(svn r23588) -Codechange: use the 'final' keyword so compiler can optimise out some indirect calls
smatz <smatz@openttd.org>
parents:
18362
diff
changeset
|
155 #else |
3dcacc91f96f
(svn r23588) -Codechange: use the 'final' keyword so compiler can optimise out some indirect calls
smatz <smatz@openttd.org>
parents:
18362
diff
changeset
|
156 #define FINAL |
3dcacc91f96f
(svn r23588) -Codechange: use the 'final' keyword so compiler can optimise out some indirect calls
smatz <smatz@openttd.org>
parents:
18362
diff
changeset
|
157 #endif |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
158 #endif /* __GNUC__ */ |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
159 |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
160 #if defined(__WATCOMC__) |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
161 #define NORETURN |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
162 #define CDECL |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
163 #define GCC_PACK |
11875
86fca539ec7a
(svn r16269) -Codechange: use gcc's ability to check parameters sent to printf-like functions
smatz <smatz@openttd.org>
parents:
11531
diff
changeset
|
164 #define WARN_FORMAT(string, args) |
18740
3dcacc91f96f
(svn r23588) -Codechange: use the 'final' keyword so compiler can optimise out some indirect calls
smatz <smatz@openttd.org>
parents:
18362
diff
changeset
|
165 #define FINAL |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
166 #include <malloc.h> |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
167 #endif /* __WATCOMC__ */ |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
168 |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
169 #if defined(__MINGW32__) || defined(__CYGWIN__) |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
170 #include <malloc.h> // alloca() |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
171 #endif |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
172 |
9256
8b6ba58e370c
(svn r13122) -Fix: WIN32_LEAN_AND_MEAN define is needed for all WIN32 compilers
glx <glx@openttd.org>
parents:
9117
diff
changeset
|
173 #if defined(WIN32) |
8b6ba58e370c
(svn r13122) -Fix: WIN32_LEAN_AND_MEAN define is needed for all WIN32 compilers
glx <glx@openttd.org>
parents:
9117
diff
changeset
|
174 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers |
8b6ba58e370c
(svn r13122) -Fix: WIN32_LEAN_AND_MEAN define is needed for all WIN32 compilers
glx <glx@openttd.org>
parents:
9117
diff
changeset
|
175 #endif |
8b6ba58e370c
(svn r13122) -Fix: WIN32_LEAN_AND_MEAN define is needed for all WIN32 compilers
glx <glx@openttd.org>
parents:
9117
diff
changeset
|
176 |
5934
3af431a1ae93
(svn r8573) -Cleanup: obey the comment style in stdafx.h.
rubidium <rubidium@openttd.org>
parents:
5933
diff
changeset
|
177 /* Stuff for MSVC */ |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
178 #if defined(_MSC_VER) |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
179 #pragma once |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
180 /* Define a win32 target platform, to override defaults of the SDK |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
181 * We need to define NTDDI version for Vista SDK, but win2k is minimum */ |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
182 #define NTDDI_VERSION NTDDI_WIN2K // Windows 2000 |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
183 #define _WIN32_WINNT 0x0500 // Windows 2000 |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
184 #define _WIN32_WINDOWS 0x400 // Windows 95 |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
185 #if !defined(WINCE) |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
186 #define WINVER 0x0400 // Windows NT 4.0 / Windows 95 |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
187 #endif |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
188 #define _WIN32_IE_ 0x0401 // 4.01 (win98 and NT4SP5+) |
19513
ef73bb2e6767
(svn r24416) -Fix [FS#5231]: [Win32] Unbreak NewGRF MD5 sum calculation. Macros and side effects don't mix, especially if there's some obscure '#define min' in a windows header that nobody thinks of.
michi_cc <michi_cc@openttd.org>
parents:
18792
diff
changeset
|
189 #define NOMINMAX // Disable min/max macros in windows.h. |
6194
bf3c126349b4
(svn r8974) -Fix: [win32] Define a win32 target platform ourselves so that we don't conflict with Vista Platform SDK (boekabart)
Darkvater <Darkvater@openttd.org>
parents:
6083
diff
changeset
|
190 |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
191 #pragma warning(disable: 4244) // 'conversion' conversion from 'type1' to 'type2', possible loss of data |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
192 #pragma warning(disable: 4761) // integral size mismatch in argument : conversion supplied |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
193 #pragma warning(disable: 4200) // nonstandard extension used : zero-sized array in struct/union |
19849
6a49909266a0
(svn r24782) -Codechange: [Win32] Disable MSVC warning about using 'this' in a base member initializer list as we don't use it in any problematic way.
michi_cc <michi_cc@openttd.org>
parents:
19513
diff
changeset
|
194 #pragma warning(disable: 4355) // 'this' : used in base member initializer list |
6194
bf3c126349b4
(svn r8974) -Fix: [win32] Define a win32 target platform ourselves so that we don't conflict with Vista Platform SDK (boekabart)
Darkvater <Darkvater@openttd.org>
parents:
6083
diff
changeset
|
195 |
8409
7c5e4180e2b1
(svn r11979) -Codechange: drop MSVC 2003 support because MSVC 2003 is broken in such a manner that it triggers an internal compiler error without any clue what of the code is wrong. Even trying to bisect the problem does not give a single line of code that causes the trouble.
rubidium <rubidium@openttd.org>
parents:
8373
diff
changeset
|
196 #if (_MSC_VER < 1400) // MSVC 2005 safety checks |
10957
132f9d86265b
(svn r15296) -Cleanup: remove redundant _MSC_VER >= 1400 checks, older versions aren't supported anymore. One check in stdafx.h is enough
smatz <smatz@openttd.org>
parents:
10936
diff
changeset
|
197 #error "Only MSVC 2005 or higher are supported. MSVC 2003 and earlier are not! Upgrade your compiler." |
8409
7c5e4180e2b1
(svn r11979) -Codechange: drop MSVC 2003 support because MSVC 2003 is broken in such a manner that it triggers an internal compiler error without any clue what of the code is wrong. Even trying to bisect the problem does not give a single line of code that causes the trouble.
rubidium <rubidium@openttd.org>
parents:
8373
diff
changeset
|
198 #endif /* (_MSC_VER < 1400) */ |
13526
46880b7248c5
(svn r18045) -Fix: GCC 4.5@HEAD not compiling OpenTTD anymore because of a "non-placement deallocation function [is] selected for placement delete", or in other words delete(void *, size_t) is 'magic'.
rubidium <rubidium@openttd.org>
parents:
13301
diff
changeset
|
199 #pragma warning(disable: 4291) // no matching operator delete found; memory will not be freed if initialization throws an exception (reason: our overloaded functions never throw an exception) |
16945
32309494f10d
(svn r21680) -Fix (r21656): of course MSVC complains
glx <glx@openttd.org>
parents:
15224
diff
changeset
|
200 #pragma warning(disable: 4996) // 'function': was declared deprecated |
8409
7c5e4180e2b1
(svn r11979) -Codechange: drop MSVC 2003 support because MSVC 2003 is broken in such a manner that it triggers an internal compiler error without any clue what of the code is wrong. Even trying to bisect the problem does not give a single line of code that causes the trouble.
rubidium <rubidium@openttd.org>
parents:
8373
diff
changeset
|
201 #define _CRT_SECURE_NO_DEPRECATE // all deprecated 'unsafe string functions |
7c5e4180e2b1
(svn r11979) -Codechange: drop MSVC 2003 support because MSVC 2003 is broken in such a manner that it triggers an internal compiler error without any clue what of the code is wrong. Even trying to bisect the problem does not give a single line of code that causes the trouble.
rubidium <rubidium@openttd.org>
parents:
8373
diff
changeset
|
202 #pragma warning(disable: 6308) // code analyzer: 'realloc' might return null pointer: assigning null pointer to 't_ptr', which is passed as an argument to 'realloc', will cause the original memory block to be leaked |
7c5e4180e2b1
(svn r11979) -Codechange: drop MSVC 2003 support because MSVC 2003 is broken in such a manner that it triggers an internal compiler error without any clue what of the code is wrong. Even trying to bisect the problem does not give a single line of code that causes the trouble.
rubidium <rubidium@openttd.org>
parents:
8373
diff
changeset
|
203 #pragma warning(disable: 6011) // code analyzer: Dereferencing NULL pointer 'pfGetAddrInfo': Lines: 995, 996, 998, 999, 1001 |
7c5e4180e2b1
(svn r11979) -Codechange: drop MSVC 2003 support because MSVC 2003 is broken in such a manner that it triggers an internal compiler error without any clue what of the code is wrong. Even trying to bisect the problem does not give a single line of code that causes the trouble.
rubidium <rubidium@openttd.org>
parents:
8373
diff
changeset
|
204 #pragma warning(disable: 6326) // code analyzer: potential comparison of a constant with another constant |
7c5e4180e2b1
(svn r11979) -Codechange: drop MSVC 2003 support because MSVC 2003 is broken in such a manner that it triggers an internal compiler error without any clue what of the code is wrong. Even trying to bisect the problem does not give a single line of code that causes the trouble.
rubidium <rubidium@openttd.org>
parents:
8373
diff
changeset
|
205 #pragma warning(disable: 6031) // code analyzer: Return value ignored: 'ReadFile' |
7c5e4180e2b1
(svn r11979) -Codechange: drop MSVC 2003 support because MSVC 2003 is broken in such a manner that it triggers an internal compiler error without any clue what of the code is wrong. Even trying to bisect the problem does not give a single line of code that causes the trouble.
rubidium <rubidium@openttd.org>
parents:
8373
diff
changeset
|
206 #pragma warning(disable: 6255) // code analyzer: _alloca indicates failure by raising a stack overflow exception. Consider using _malloca instead |
7c5e4180e2b1
(svn r11979) -Codechange: drop MSVC 2003 support because MSVC 2003 is broken in such a manner that it triggers an internal compiler error without any clue what of the code is wrong. Even trying to bisect the problem does not give a single line of code that causes the trouble.
rubidium <rubidium@openttd.org>
parents:
8373
diff
changeset
|
207 #pragma warning(disable: 6246) // code analyzer: Local declaration of 'statspec' hides declaration of the same name in outer scope. For additional information, see previous declaration at ... |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
208 |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
209 #include <malloc.h> // alloca() |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
210 #define NORETURN __declspec(noreturn) |
18792
c99e695378ce
(svn r23640) -Fix: stop using FORCEINLINE (1/3rd of the instances were, the others were still regular inline), but make sure inline is always a 'forced' inline (I am looking at you MSVC)
truebrain <truebrain@openttd.org>
parents:
18740
diff
changeset
|
211 #define inline __forceinline |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
212 |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
213 #if !defined(WINCE) |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
214 #define CDECL _cdecl |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
215 #endif |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
216 |
12298
892bc121d963
(svn r16715) -Codechange: add attribute to assert_compile(), so it doesn't warn when used inside function
smatz <smatz@openttd.org>
parents:
12083
diff
changeset
|
217 #define GCC_PACK |
18740
3dcacc91f96f
(svn r23588) -Codechange: use the 'final' keyword so compiler can optimise out some indirect calls
smatz <smatz@openttd.org>
parents:
18362
diff
changeset
|
218 #define WARN_FORMAT(string, args) |
3dcacc91f96f
(svn r23588) -Codechange: use the 'final' keyword so compiler can optimise out some indirect calls
smatz <smatz@openttd.org>
parents:
18362
diff
changeset
|
219 #define FINAL sealed |
12298
892bc121d963
(svn r16715) -Codechange: add attribute to assert_compile(), so it doesn't warn when used inside function
smatz <smatz@openttd.org>
parents:
12083
diff
changeset
|
220 |
11875
86fca539ec7a
(svn r16269) -Codechange: use gcc's ability to check parameters sent to printf-like functions
smatz <smatz@openttd.org>
parents:
11531
diff
changeset
|
221 int CDECL snprintf(char *str, size_t size, const char *format, ...) WARN_FORMAT(3, 4); |
10957
132f9d86265b
(svn r15296) -Cleanup: remove redundant _MSC_VER >= 1400 checks, older versions aren't supported anymore. One check in stdafx.h is enough
smatz <smatz@openttd.org>
parents:
10936
diff
changeset
|
222 #if defined(WINCE) |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
223 int CDECL vsnprintf(char *str, size_t size, const char *format, va_list ap); |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
224 #endif |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
225 |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
226 #if defined(WIN32) && !defined(_WIN64) && !defined(WIN64) |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
227 #if !defined(_W64) |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
228 #define _W64 |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
229 #endif |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
230 |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
231 typedef _W64 int INT_PTR, *PINT_PTR; |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
232 typedef _W64 unsigned int UINT_PTR, *PUINT_PTR; |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
233 #endif /* WIN32 && !_WIN64 && !WIN64 */ |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
234 |
9390
45c874394355
(svn r13301) -Fix [FS#1997]: resolve more MSVC 9 x64 warnings.
rubidium <rubidium@openttd.org>
parents:
9256
diff
changeset
|
235 #if defined(_WIN64) || defined(WIN64) |
45c874394355
(svn r13301) -Fix [FS#1997]: resolve more MSVC 9 x64 warnings.
rubidium <rubidium@openttd.org>
parents:
9256
diff
changeset
|
236 #define fseek _fseeki64 |
45c874394355
(svn r13301) -Fix [FS#1997]: resolve more MSVC 9 x64 warnings.
rubidium <rubidium@openttd.org>
parents:
9256
diff
changeset
|
237 #endif /* _WIN64 || WIN64 */ |
45c874394355
(svn r13301) -Fix [FS#1997]: resolve more MSVC 9 x64 warnings.
rubidium <rubidium@openttd.org>
parents:
9256
diff
changeset
|
238 |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
239 /* This is needed to zlib uses the stdcall calling convention on visual studio */ |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
240 #if defined(WITH_ZLIB) || defined(WITH_PNG) |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
241 #if !defined(ZLIB_WINAPI) |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
242 #define ZLIB_WINAPI |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
243 #endif |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
244 #endif |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
245 |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
246 #if defined(WINCE) |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
247 #define strcasecmp _stricmp |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
248 #define strncasecmp _strnicmp |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
249 #undef DEBUG |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
250 #else |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
251 #define strcasecmp stricmp |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
252 #define strncasecmp strnicmp |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
253 #endif |
8051
ac548999eddf
(svn r11611) -Codechange: it is now possible to use a define to enable asserts and show them in crash.log for MSVC release builds
glx <glx@openttd.org>
parents:
8050
diff
changeset
|
254 |
10384
b0837d51a306
(svn r14635) -Change: use S_ISDIR/S_ISREG as x & S_IFREG always results false on platforms when S_IFREG is 0x0000.
rubidium <rubidium@openttd.org>
parents:
10308
diff
changeset
|
255 /* MSVC doesn't have these :( */ |
b0837d51a306
(svn r14635) -Change: use S_ISDIR/S_ISREG as x & S_IFREG always results false on platforms when S_IFREG is 0x0000.
rubidium <rubidium@openttd.org>
parents:
10308
diff
changeset
|
256 #define S_ISDIR(mode) (mode & S_IFDIR) |
b0837d51a306
(svn r14635) -Change: use S_ISDIR/S_ISREG as x & S_IFREG always results false on platforms when S_IFREG is 0x0000.
rubidium <rubidium@openttd.org>
parents:
10308
diff
changeset
|
257 #define S_ISREG(mode) (mode & S_IFREG) |
b0837d51a306
(svn r14635) -Change: use S_ISDIR/S_ISREG as x & S_IFREG always results false on platforms when S_IFREG is 0x0000.
rubidium <rubidium@openttd.org>
parents:
10308
diff
changeset
|
258 |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
259 #endif /* defined(_MSC_VER) */ |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
260 |
14669
7dfc887eabce
(svn r19248) -Fix: DOS 'port' did not compile anymore
rubidium <rubidium@openttd.org>
parents:
14600
diff
changeset
|
261 #if defined(DOS) |
7dfc887eabce
(svn r19248) -Fix: DOS 'port' did not compile anymore
rubidium <rubidium@openttd.org>
parents:
14600
diff
changeset
|
262 /* The DOS port does not have all signals/signal functions. */ |
7dfc887eabce
(svn r19248) -Fix: DOS 'port' did not compile anymore
rubidium <rubidium@openttd.org>
parents:
14600
diff
changeset
|
263 #define strsignal(sig) "" |
15002
baf0e12ad2b4
(svn r19614) -Codechange: "it's" => "its" where appropriate
smatz <smatz@openttd.org>
parents:
14992
diff
changeset
|
264 /* Use 'no floating point' for bus errors; SIGBUS does not exist |
baf0e12ad2b4
(svn r19614) -Codechange: "it's" => "its" where appropriate
smatz <smatz@openttd.org>
parents:
14992
diff
changeset
|
265 * for DOS, SIGNOFP for other platforms. So it's fairly safe |
baf0e12ad2b4
(svn r19614) -Codechange: "it's" => "its" where appropriate
smatz <smatz@openttd.org>
parents:
14992
diff
changeset
|
266 * to interchange those. */ |
14669
7dfc887eabce
(svn r19248) -Fix: DOS 'port' did not compile anymore
rubidium <rubidium@openttd.org>
parents:
14600
diff
changeset
|
267 #define SIGBUS SIGNOFP |
7dfc887eabce
(svn r19248) -Fix: DOS 'port' did not compile anymore
rubidium <rubidium@openttd.org>
parents:
14600
diff
changeset
|
268 #endif |
7dfc887eabce
(svn r19248) -Fix: DOS 'port' did not compile anymore
rubidium <rubidium@openttd.org>
parents:
14600
diff
changeset
|
269 |
5755
81b21aaedc57
(svn r8306) [WinCE] -Fix: some functions don't exists in WinCE, so give an alternative where possible
truelight <truelight@openttd.org>
parents:
5671
diff
changeset
|
270 #if defined(WINCE) |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
271 #define strdup _strdup |
5755
81b21aaedc57
(svn r8306) [WinCE] -Fix: some functions don't exists in WinCE, so give an alternative where possible
truelight <truelight@openttd.org>
parents:
5671
diff
changeset
|
272 #endif /* WINCE */ |
81b21aaedc57
(svn r8306) [WinCE] -Fix: some functions don't exists in WinCE, so give an alternative where possible
truelight <truelight@openttd.org>
parents:
5671
diff
changeset
|
273 |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
274 /* NOTE: the string returned by these functions is only valid until the next |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
275 * call to the same function and is not thread- or reentrancy-safe */ |
17421
579c528e8fc8
(svn r22171) -Add: Add settings generator program.
alberth <alberth@openttd.org>
parents:
17301
diff
changeset
|
276 #if !defined(STRGEN) && !defined(SETTINGSGEN) |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
277 #if defined(WIN32) || defined(WIN64) |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
278 char *getcwd(char *buf, size_t size); |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
279 #include <tchar.h> |
11360
4bf4f1f53b12
(svn r15710) -Fix (r15706): for non MSVC io.h needs to be included before defining unlink. Also remove redundant tchar.h includes as it is already in stdafx.h.
glx <glx@openttd.org>
parents:
11356
diff
changeset
|
280 #include <io.h> |
6251
9953c75f16bc
(svn r9055) -Codechange: Change windows unicode handling and allow a pure non-unicode build to function. Win9x binaries will be possible with mingw/nightly system.
Darkvater <Darkvater@openttd.org>
parents:
6233
diff
changeset
|
281 |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
282 /* XXX - WinCE without MSVCRT doesn't support wfopen, so it seems */ |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
283 #if !defined(WINCE) |
15158
b4516bc34b30
(svn r19787) -Fix: compilation with MinGW GCC 4.5.0 and UNICODE
glx <glx@openttd.org>
parents:
15152
diff
changeset
|
284 namespace std { using ::_tfopen; } |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
285 #define fopen(file, mode) _tfopen(OTTD2FS(file), _T(mode)) |
11356
99326e76187e
(svn r15706) -Fix: Make sure the filename passed to unlink() is always in file system encoding.
michi_cc <michi_cc@openttd.org>
parents:
10957
diff
changeset
|
286 #define unlink(file) _tunlink(OTTD2FS(file)) |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
287 #endif /* WINCE */ |
6251
9953c75f16bc
(svn r9055) -Codechange: Change windows unicode handling and allow a pure non-unicode build to function. Win9x binaries will be possible with mingw/nightly system.
Darkvater <Darkvater@openttd.org>
parents:
6233
diff
changeset
|
288 |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
289 const char *FS2OTTD(const TCHAR *name); |
20699
d198fbc52efc
-Fix: [Win32] The console code page for non-Unicode builds is not the normal ANSI code page and definitely not UTF-8 either.
Michael Lutz <michi@icosahedron.de>
parents:
20179
diff
changeset
|
290 const TCHAR *OTTD2FS(const char *name, bool console_cp = false); |
14310
84c12fbfc0f1
(svn r18862) -Fix [FS#3544]: don't pass AI strings through iconv
rubidium <rubidium@openttd.org>
parents:
13536
diff
changeset
|
291 #define SQ2OTTD(name) FS2OTTD(name) |
84c12fbfc0f1
(svn r18862) -Fix [FS#3544]: don't pass AI strings through iconv
rubidium <rubidium@openttd.org>
parents:
13536
diff
changeset
|
292 #define OTTD2SQ(name) OTTD2FS(name) |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
293 #else |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
294 #define fopen(file, mode) fopen(OTTD2FS(file), mode) |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
295 const char *FS2OTTD(const char *name); |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
296 const char *OTTD2FS(const char *name); |
14310
84c12fbfc0f1
(svn r18862) -Fix [FS#3544]: don't pass AI strings through iconv
rubidium <rubidium@openttd.org>
parents:
13536
diff
changeset
|
297 #define SQ2OTTD(name) (name) |
84c12fbfc0f1
(svn r18862) -Fix [FS#3544]: don't pass AI strings through iconv
rubidium <rubidium@openttd.org>
parents:
13536
diff
changeset
|
298 #define OTTD2SQ(name) (name) |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
299 #endif /* WIN32 */ |
17421
579c528e8fc8
(svn r22171) -Add: Add settings generator program.
alberth <alberth@openttd.org>
parents:
17301
diff
changeset
|
300 #endif /* STRGEN || SETTINGSGEN */ |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
301 |
5591
cf00a1ba52bc
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge <orudge@openttd.org>
parents:
5587
diff
changeset
|
302 #if defined(WIN32) || defined(WIN64) || defined(__OS2__) && !defined(__INNOTEK_LIBC__) |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
303 #define PATHSEP "\\" |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
304 #define PATHSEPCHAR '\\' |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
305 #else |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
306 #define PATHSEP "/" |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
307 #define PATHSEPCHAR '/' |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
308 #endif |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
309 |
11875
86fca539ec7a
(svn r16269) -Codechange: use gcc's ability to check parameters sent to printf-like functions
smatz <smatz@openttd.org>
parents:
11531
diff
changeset
|
310 /* MSVCRT of course has to have a different syntax for long long *sigh* */ |
86fca539ec7a
(svn r16269) -Codechange: use gcc's ability to check parameters sent to printf-like functions
smatz <smatz@openttd.org>
parents:
11531
diff
changeset
|
311 #if defined(_MSC_VER) || defined(__MINGW32__) |
86fca539ec7a
(svn r16269) -Codechange: use gcc's ability to check parameters sent to printf-like functions
smatz <smatz@openttd.org>
parents:
11531
diff
changeset
|
312 #define OTTD_PRINTF64 "%I64d" |
14962
c2219aa06da1
(svn r19570) -Add: [NewGRF] support for extended text code 0x9A 11, print qword
yexo <yexo@openttd.org>
parents:
14764
diff
changeset
|
313 #define OTTD_PRINTFHEX64 "%I64x" |
11875
86fca539ec7a
(svn r16269) -Codechange: use gcc's ability to check parameters sent to printf-like functions
smatz <smatz@openttd.org>
parents:
11531
diff
changeset
|
314 #define PRINTF_SIZE "%Iu" |
86fca539ec7a
(svn r16269) -Codechange: use gcc's ability to check parameters sent to printf-like functions
smatz <smatz@openttd.org>
parents:
11531
diff
changeset
|
315 #else |
86fca539ec7a
(svn r16269) -Codechange: use gcc's ability to check parameters sent to printf-like functions
smatz <smatz@openttd.org>
parents:
11531
diff
changeset
|
316 #define OTTD_PRINTF64 "%lld" |
14962
c2219aa06da1
(svn r19570) -Add: [NewGRF] support for extended text code 0x9A 11, print qword
yexo <yexo@openttd.org>
parents:
14764
diff
changeset
|
317 #define OTTD_PRINTFHEX64 "%llx" |
11875
86fca539ec7a
(svn r16269) -Codechange: use gcc's ability to check parameters sent to printf-like functions
smatz <smatz@openttd.org>
parents:
11531
diff
changeset
|
318 #define PRINTF_SIZE "%zu" |
86fca539ec7a
(svn r16269) -Codechange: use gcc's ability to check parameters sent to printf-like functions
smatz <smatz@openttd.org>
parents:
11531
diff
changeset
|
319 #endif |
86fca539ec7a
(svn r16269) -Codechange: use gcc's ability to check parameters sent to printf-like functions
smatz <smatz@openttd.org>
parents:
11531
diff
changeset
|
320 |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
321 typedef unsigned char byte; |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
322 |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
323 /* This is already defined in unix, but not in QNX Neutrino (6.x)*/ |
13105
e1e6490148f5
(svn r17606) -Add: initial support for Haiku; a dedicated server with zlib and libpng compiles and links (for me). Something's fishy with the network so it doesn't actually work (yet)
rubidium <rubidium@openttd.org>
parents:
12971
diff
changeset
|
324 #if (!defined(UNIX) && !defined(__CYGWIN__) && !defined(__BEOS__) && !defined(__HAIKU__) && !defined(__MORPHOS__)) || defined(__QNXNTO__) |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
325 typedef unsigned int uint; |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
326 #endif |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
327 |
13105
e1e6490148f5
(svn r17606) -Add: initial support for Haiku; a dedicated server with zlib and libpng compiles and links (for me). Something's fishy with the network so it doesn't actually work (yet)
rubidium <rubidium@openttd.org>
parents:
12971
diff
changeset
|
328 #if defined(TROUBLED_INTS) |
e1e6490148f5
(svn r17606) -Add: initial support for Haiku; a dedicated server with zlib and libpng compiles and links (for me). Something's fishy with the network so it doesn't actually work (yet)
rubidium <rubidium@openttd.org>
parents:
12971
diff
changeset
|
329 /* NDS'/BeOS'/Haiku's types for uint32/int32 are based on longs, which causes |
e1e6490148f5
(svn r17606) -Add: initial support for Haiku; a dedicated server with zlib and libpng compiles and links (for me). Something's fishy with the network so it doesn't actually work (yet)
rubidium <rubidium@openttd.org>
parents:
12971
diff
changeset
|
330 * trouble all over the place in OpenTTD. */ |
e1e6490148f5
(svn r17606) -Add: initial support for Haiku; a dedicated server with zlib and libpng compiles and links (for me). Something's fishy with the network so it doesn't actually work (yet)
rubidium <rubidium@openttd.org>
parents:
12971
diff
changeset
|
331 #define uint32 uint32_ugly_hack |
e1e6490148f5
(svn r17606) -Add: initial support for Haiku; a dedicated server with zlib and libpng compiles and links (for me). Something's fishy with the network so it doesn't actually work (yet)
rubidium <rubidium@openttd.org>
parents:
12971
diff
changeset
|
332 #define int32 int32_ugly_hack |
e1e6490148f5
(svn r17606) -Add: initial support for Haiku; a dedicated server with zlib and libpng compiles and links (for me). Something's fishy with the network so it doesn't actually work (yet)
rubidium <rubidium@openttd.org>
parents:
12971
diff
changeset
|
333 typedef unsigned int uint32_ugly_hack; |
e1e6490148f5
(svn r17606) -Add: initial support for Haiku; a dedicated server with zlib and libpng compiles and links (for me). Something's fishy with the network so it doesn't actually work (yet)
rubidium <rubidium@openttd.org>
parents:
12971
diff
changeset
|
334 typedef signed int int32_ugly_hack; |
e1e6490148f5
(svn r17606) -Add: initial support for Haiku; a dedicated server with zlib and libpng compiles and links (for me). Something's fishy with the network so it doesn't actually work (yet)
rubidium <rubidium@openttd.org>
parents:
12971
diff
changeset
|
335 #else |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
336 typedef unsigned char uint8; |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
337 typedef signed char int8; |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
338 typedef unsigned short uint16; |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
339 typedef signed short int16; |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
340 typedef unsigned int uint32; |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
341 typedef signed int int32; |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
342 typedef unsigned __int64 uint64; |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
343 typedef signed __int64 int64; |
13105
e1e6490148f5
(svn r17606) -Add: initial support for Haiku; a dedicated server with zlib and libpng compiles and links (for me). Something's fishy with the network so it doesn't actually work (yet)
rubidium <rubidium@openttd.org>
parents:
12971
diff
changeset
|
344 #endif /* !TROUBLED_INTS */ |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
345 |
6929
bb43858bed10
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents:
6834
diff
changeset
|
346 #if !defined(WITH_PERSONAL_DIR) |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
347 #define PERSONAL_DIR "" |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
348 #endif |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
349 |
14992
67870be3d58f
(svn r19604) -Codechange: Reintroduce assert_tcompile().
frosch <frosch@openttd.org>
parents:
14962
diff
changeset
|
350 /* Compile time assertions. Prefer c++0x static_assert(). |
67870be3d58f
(svn r19604) -Codechange: Reintroduce assert_tcompile().
frosch <frosch@openttd.org>
parents:
14962
diff
changeset
|
351 * Older compilers cannot evaluate some expressions at compile time, |
67870be3d58f
(svn r19604) -Codechange: Reintroduce assert_tcompile().
frosch <frosch@openttd.org>
parents:
14962
diff
changeset
|
352 * typically when templates are involved, try assert_tcompile() in those cases. */ |
12971
88cf8dd8495c
(svn r17465) -Codechange: use builtin static_assert() for assert_compile() if available
smatz <smatz@openttd.org>
parents:
12960
diff
changeset
|
353 #if defined(__STDCXX_VERSION__) || defined(__GXX_EXPERIMENTAL_CXX0X__) || defined(__GXX_EXPERIMENTAL_CPP0X__) || defined(static_assert) |
88cf8dd8495c
(svn r17465) -Codechange: use builtin static_assert() for assert_compile() if available
smatz <smatz@openttd.org>
parents:
12960
diff
changeset
|
354 /* __STDCXX_VERSION__ is c++0x feature macro, __GXX_EXPERIMENTAL_CXX0X__ is used by gcc, __GXX_EXPERIMENTAL_CPP0X__ by icc */ |
88cf8dd8495c
(svn r17465) -Codechange: use builtin static_assert() for assert_compile() if available
smatz <smatz@openttd.org>
parents:
12960
diff
changeset
|
355 #define assert_compile(expr) static_assert(expr, #expr ) |
14992
67870be3d58f
(svn r19604) -Codechange: Reintroduce assert_tcompile().
frosch <frosch@openttd.org>
parents:
14962
diff
changeset
|
356 #define assert_tcompile(expr) assert_compile(expr) |
13536
7ec81219f539
(svn r18057) -Codechange: replace assert_compile() by new one which works with gcc3.3 and removes the need of assert_tcompile()
smatz <smatz@openttd.org>
parents:
13526
diff
changeset
|
357 #elif defined(__OS2__) |
7ec81219f539
(svn r18057) -Codechange: replace assert_compile() by new one which works with gcc3.3 and removes the need of assert_tcompile()
smatz <smatz@openttd.org>
parents:
13526
diff
changeset
|
358 /* Disabled for OS/2 */ |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
359 #define assert_compile(expr) |
14992
67870be3d58f
(svn r19604) -Codechange: Reintroduce assert_tcompile().
frosch <frosch@openttd.org>
parents:
14962
diff
changeset
|
360 #define assert_tcompile(expr) assert_compile(expr) |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
361 #else |
13536
7ec81219f539
(svn r18057) -Codechange: replace assert_compile() by new one which works with gcc3.3 and removes the need of assert_tcompile()
smatz <smatz@openttd.org>
parents:
13526
diff
changeset
|
362 #define assert_compile(expr) typedef int __ct_assert__[1 - 2 * !(expr)] |
14992
67870be3d58f
(svn r19604) -Codechange: Reintroduce assert_tcompile().
frosch <frosch@openttd.org>
parents:
14962
diff
changeset
|
363 #define assert_tcompile(expr) assert(expr) |
12971
88cf8dd8495c
(svn r17465) -Codechange: use builtin static_assert() for assert_compile() if available
smatz <smatz@openttd.org>
parents:
12960
diff
changeset
|
364 #endif |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
365 |
8678
c662110e3c06
(svn r12344) -Codechange: Check uint64 bitsize on compiletime too.
skidd13 <skidd13@openttd.org>
parents:
8409
diff
changeset
|
366 /* Check if the types have the bitsizes like we are using them */ |
c662110e3c06
(svn r12344) -Codechange: Check uint64 bitsize on compiletime too.
skidd13 <skidd13@openttd.org>
parents:
8409
diff
changeset
|
367 assert_compile(sizeof(uint64) == 8); |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
368 assert_compile(sizeof(uint32) == 4); |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
369 assert_compile(sizeof(uint16) == 2); |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
370 assert_compile(sizeof(uint8) == 1); |
18066
4871848c9435
(svn r22881) -Fix (r22875): GCC warnings on 64bit systems.
frosch <frosch@openttd.org>
parents:
18060
diff
changeset
|
371 assert_compile(SIZE_MAX >= UINT32_MAX); |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
372 |
14764
6c9a2c3f21c5
(svn r19352) -Fix (r19332): MSVC doesn't have M_PI in math.h
yexo <yexo@openttd.org>
parents:
14669
diff
changeset
|
373 #ifndef M_PI_2 |
6c9a2c3f21c5
(svn r19352) -Fix (r19332): MSVC doesn't have M_PI in math.h
yexo <yexo@openttd.org>
parents:
14669
diff
changeset
|
374 #define M_PI_2 1.57079632679489661923 |
6c9a2c3f21c5
(svn r19352) -Fix (r19332): MSVC doesn't have M_PI in math.h
yexo <yexo@openttd.org>
parents:
14669
diff
changeset
|
375 #define M_PI 3.14159265358979323846 |
6c9a2c3f21c5
(svn r19352) -Fix (r19332): MSVC doesn't have M_PI in math.h
yexo <yexo@openttd.org>
parents:
14669
diff
changeset
|
376 #endif /* M_PI_2 */ |
6c9a2c3f21c5
(svn r19352) -Fix (r19332): MSVC doesn't have M_PI in math.h
yexo <yexo@openttd.org>
parents:
14669
diff
changeset
|
377 |
10308
7f52d0f68806
(svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents:
9997
diff
changeset
|
378 /** |
7f52d0f68806
(svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents:
9997
diff
changeset
|
379 * Return the length of an fixed size array. |
7f52d0f68806
(svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents:
9997
diff
changeset
|
380 * Unlike sizeof this function returns the number of elements |
7f52d0f68806
(svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents:
9997
diff
changeset
|
381 * of the given type. |
7f52d0f68806
(svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents:
9997
diff
changeset
|
382 * |
7f52d0f68806
(svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents:
9997
diff
changeset
|
383 * @param x The pointer to the first element of the array |
7f52d0f68806
(svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents:
9997
diff
changeset
|
384 * @return The number of elements |
7f52d0f68806
(svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents:
9997
diff
changeset
|
385 */ |
9117
453c3d26f4bc
(svn r12977) -Codechange: remove quite some redundant (duplicate) function declarations.
rubidium <rubidium@openttd.org>
parents:
9111
diff
changeset
|
386 #define lengthof(x) (sizeof(x) / sizeof(x[0])) |
10308
7f52d0f68806
(svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents:
9997
diff
changeset
|
387 |
7f52d0f68806
(svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents:
9997
diff
changeset
|
388 /** |
7f52d0f68806
(svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents:
9997
diff
changeset
|
389 * Get the end element of an fixed size array. |
7f52d0f68806
(svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents:
9997
diff
changeset
|
390 * |
7f52d0f68806
(svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents:
9997
diff
changeset
|
391 * @param x The pointer to the first element of the array |
7f52d0f68806
(svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents:
9997
diff
changeset
|
392 * @return The pointer past to the last element of the array |
7f52d0f68806
(svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents:
9997
diff
changeset
|
393 */ |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
394 #define endof(x) (&x[lengthof(x)]) |
10308
7f52d0f68806
(svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents:
9997
diff
changeset
|
395 |
7f52d0f68806
(svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents:
9997
diff
changeset
|
396 /** |
7f52d0f68806
(svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents:
9997
diff
changeset
|
397 * Get the last element of an fixed size array. |
7f52d0f68806
(svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents:
9997
diff
changeset
|
398 * |
7f52d0f68806
(svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents:
9997
diff
changeset
|
399 * @param x The pointer to the first element of the array |
7f52d0f68806
(svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents:
9997
diff
changeset
|
400 * @return The pointer to the last element of the array |
7f52d0f68806
(svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents:
9997
diff
changeset
|
401 */ |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
402 #define lastof(x) (&x[lengthof(x) - 1]) |
5671
025a6bc5e2e5
(svn r8131) -Fix (r8125): g++ warning: 'invalid access to non-static data member ‘<class>::<member>’ of NULL object'. It is weird, but renaming the 'offsetof' macro helped.
KUDr <KUDr@openttd.org>
parents:
5591
diff
changeset
|
403 |
8969
01cc3ee6ecb1
(svn r12761) -Codechange: lots of minor whitespace coding style fixes around operators.
rubidium <rubidium@openttd.org>
parents:
8825
diff
changeset
|
404 #define cpp_offsetof(s, m) (((size_t)&reinterpret_cast<const volatile char&>((((s*)(char*)8)->m))) - 8) |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
405 #if !defined(offsetof) |
8969
01cc3ee6ecb1
(svn r12761) -Codechange: lots of minor whitespace coding style fixes around operators.
rubidium <rubidium@openttd.org>
parents:
8825
diff
changeset
|
406 #define offsetof(s, m) cpp_offsetof(s, m) |
6083
37a5650e8596
(svn r8818) -Codechange: remove the #ifdef _cplusplus remnants.
rubidium <rubidium@openttd.org>
parents:
5976
diff
changeset
|
407 #endif /* offsetof */ |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
408 |
15072
0f1869a54166
(svn r19698) -Add: macros to get the size/length of a variable within a class
rubidium <rubidium@openttd.org>
parents:
15002
diff
changeset
|
409 /** |
0f1869a54166
(svn r19698) -Add: macros to get the size/length of a variable within a class
rubidium <rubidium@openttd.org>
parents:
15002
diff
changeset
|
410 * Gets the size of a variable within a class. |
0f1869a54166
(svn r19698) -Add: macros to get the size/length of a variable within a class
rubidium <rubidium@openttd.org>
parents:
15002
diff
changeset
|
411 * @param base The class the variable is in. |
0f1869a54166
(svn r19698) -Add: macros to get the size/length of a variable within a class
rubidium <rubidium@openttd.org>
parents:
15002
diff
changeset
|
412 * @param variable The variable to get the size of. |
0f1869a54166
(svn r19698) -Add: macros to get the size/length of a variable within a class
rubidium <rubidium@openttd.org>
parents:
15002
diff
changeset
|
413 * @return the size of the variable |
0f1869a54166
(svn r19698) -Add: macros to get the size/length of a variable within a class
rubidium <rubidium@openttd.org>
parents:
15002
diff
changeset
|
414 */ |
0f1869a54166
(svn r19698) -Add: macros to get the size/length of a variable within a class
rubidium <rubidium@openttd.org>
parents:
15002
diff
changeset
|
415 #define cpp_sizeof(base, variable) (sizeof(((base*)8)->variable)) |
0f1869a54166
(svn r19698) -Add: macros to get the size/length of a variable within a class
rubidium <rubidium@openttd.org>
parents:
15002
diff
changeset
|
416 |
0f1869a54166
(svn r19698) -Add: macros to get the size/length of a variable within a class
rubidium <rubidium@openttd.org>
parents:
15002
diff
changeset
|
417 /** |
0f1869a54166
(svn r19698) -Add: macros to get the size/length of a variable within a class
rubidium <rubidium@openttd.org>
parents:
15002
diff
changeset
|
418 * Gets the length of an array variable within a class. |
0f1869a54166
(svn r19698) -Add: macros to get the size/length of a variable within a class
rubidium <rubidium@openttd.org>
parents:
15002
diff
changeset
|
419 * @param base The class the variable is in. |
0f1869a54166
(svn r19698) -Add: macros to get the size/length of a variable within a class
rubidium <rubidium@openttd.org>
parents:
15002
diff
changeset
|
420 * @param variable The array variable to get the size of. |
0f1869a54166
(svn r19698) -Add: macros to get the size/length of a variable within a class
rubidium <rubidium@openttd.org>
parents:
15002
diff
changeset
|
421 * @return the length of the array |
0f1869a54166
(svn r19698) -Add: macros to get the size/length of a variable within a class
rubidium <rubidium@openttd.org>
parents:
15002
diff
changeset
|
422 */ |
0f1869a54166
(svn r19698) -Add: macros to get the size/length of a variable within a class
rubidium <rubidium@openttd.org>
parents:
15002
diff
changeset
|
423 #define cpp_lengthof(base, variable) (cpp_sizeof(base, variable) / cpp_sizeof(base, variable[0])) |
0f1869a54166
(svn r19698) -Add: macros to get the size/length of a variable within a class
rubidium <rubidium@openttd.org>
parents:
15002
diff
changeset
|
424 |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
425 |
5934
3af431a1ae93
(svn r8573) -Cleanup: obey the comment style in stdafx.h.
rubidium <rubidium@openttd.org>
parents:
5933
diff
changeset
|
426 /* take care of some name clashes on MacOS */ |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
427 #if defined(__APPLE__) |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
428 #define GetString OTTD_GetString |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
429 #define DrawString OTTD_DrawString |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
430 #define CloseConnection OTTD_CloseConnection |
8126
357c22303fd6
(svn r11687) -Codechange: move some defines to a better place
skidd13 <skidd13@openttd.org>
parents:
8123
diff
changeset
|
431 #endif /* __APPLE__ */ |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
432 |
11875
86fca539ec7a
(svn r16269) -Codechange: use gcc's ability to check parameters sent to printf-like functions
smatz <smatz@openttd.org>
parents:
11531
diff
changeset
|
433 void NORETURN CDECL usererror(const char *str, ...) WARN_FORMAT(1, 2); |
86fca539ec7a
(svn r16269) -Codechange: use gcc's ability to check parameters sent to printf-like functions
smatz <smatz@openttd.org>
parents:
11531
diff
changeset
|
434 void NORETURN CDECL error(const char *str, ...) WARN_FORMAT(1, 2); |
6622
8bb80527a9e8
(svn r9842) -Codechange: now NOT_REACHED is also triggered when debugging is disabled.
rubidium <rubidium@openttd.org>
parents:
6524
diff
changeset
|
435 #define NOT_REACHED() error("NOT_REACHED triggered at line %i of %s", __LINE__, __FILE__) |
8bb80527a9e8
(svn r9842) -Codechange: now NOT_REACHED is also triggered when debugging is disabled.
rubidium <rubidium@openttd.org>
parents:
6524
diff
changeset
|
436 |
12960
e55edfe4235d
(svn r17453) -Add: crash logger for all Unixy OSes; should work for all, but I don't have all exotic machines so it might break compilation on the more exotic configurations
rubidium <rubidium@openttd.org>
parents:
12957
diff
changeset
|
437 /* For non-debug builds with assertions enabled use the special assertion handler: |
e55edfe4235d
(svn r17453) -Add: crash logger for all Unixy OSes; should work for all, but I don't have all exotic machines so it might break compilation on the more exotic configurations
rubidium <rubidium@openttd.org>
parents:
12957
diff
changeset
|
438 * - For MSVC: NDEBUG is set for all release builds and WITH_ASSERT overrides the disabling of asserts. |
e55edfe4235d
(svn r17453) -Add: crash logger for all Unixy OSes; should work for all, but I don't have all exotic machines so it might break compilation on the more exotic configurations
rubidium <rubidium@openttd.org>
parents:
12957
diff
changeset
|
439 * - For non MSVC: NDEBUG is set when assertions are disables, _DEBUG is set for non-release builds. |
e55edfe4235d
(svn r17453) -Add: crash logger for all Unixy OSes; should work for all, but I don't have all exotic machines so it might break compilation on the more exotic configurations
rubidium <rubidium@openttd.org>
parents:
12957
diff
changeset
|
440 */ |
e55edfe4235d
(svn r17453) -Add: crash logger for all Unixy OSes; should work for all, but I don't have all exotic machines so it might break compilation on the more exotic configurations
rubidium <rubidium@openttd.org>
parents:
12957
diff
changeset
|
441 #if (defined(_MSC_VER) && defined(NDEBUG) && defined(WITH_ASSERT)) || (!defined(_MSC_VER) && !defined(NDEBUG) && !defined(_DEBUG)) |
e55edfe4235d
(svn r17453) -Add: crash logger for all Unixy OSes; should work for all, but I don't have all exotic machines so it might break compilation on the more exotic configurations
rubidium <rubidium@openttd.org>
parents:
12957
diff
changeset
|
442 #undef assert |
e55edfe4235d
(svn r17453) -Add: crash logger for all Unixy OSes; should work for all, but I don't have all exotic machines so it might break compilation on the more exotic configurations
rubidium <rubidium@openttd.org>
parents:
12957
diff
changeset
|
443 #define assert(expression) if (!(expression)) error("Assertion failed at line %i of %s: %s", __LINE__, __FILE__, #expression); |
e55edfe4235d
(svn r17453) -Add: crash logger for all Unixy OSes; should work for all, but I don't have all exotic machines so it might break compilation on the more exotic configurations
rubidium <rubidium@openttd.org>
parents:
12957
diff
changeset
|
444 #endif |
e55edfe4235d
(svn r17453) -Add: crash logger for all Unixy OSes; should work for all, but I don't have all exotic machines so it might break compilation on the more exotic configurations
rubidium <rubidium@openttd.org>
parents:
12957
diff
changeset
|
445 |
17301
1c75c528b301
(svn r22041) -Codechange: add a check that we called PoolItem::CanAllocateItem() before actually allocating it
smatz <smatz@openttd.org>
parents:
16945
diff
changeset
|
446 /* Asserts are enabled if NDEBUG isn't defined, or if we are using MSVC and WITH_ASSERT is defined. */ |
1c75c528b301
(svn r22041) -Codechange: add a check that we called PoolItem::CanAllocateItem() before actually allocating it
smatz <smatz@openttd.org>
parents:
16945
diff
changeset
|
447 #if !defined(NDEBUG) || (defined(_MSC_VER) && defined(WITH_ASSERT)) |
1c75c528b301
(svn r22041) -Codechange: add a check that we called PoolItem::CanAllocateItem() before actually allocating it
smatz <smatz@openttd.org>
parents:
16945
diff
changeset
|
448 #define OTTD_ASSERT |
1c75c528b301
(svn r22041) -Codechange: add a check that we called PoolItem::CanAllocateItem() before actually allocating it
smatz <smatz@openttd.org>
parents:
16945
diff
changeset
|
449 #endif |
1c75c528b301
(svn r22041) -Codechange: add a check that we called PoolItem::CanAllocateItem() before actually allocating it
smatz <smatz@openttd.org>
parents:
16945
diff
changeset
|
450 |
10385
9709c41adf56
(svn r14636) -Add: DOS port of OpenTTD, without network support though.
rubidium <rubidium@openttd.org>
parents:
10384
diff
changeset
|
451 #if defined(MORPHOS) || defined(__NDS__) || defined(__DJGPP__) |
8373
a6209668c216
(svn r11939) -Codechange: some type fixes and very initial steps into supporting NDS by default. Based on work by Dominik.
rubidium <rubidium@openttd.org>
parents:
8292
diff
changeset
|
452 /* MorphOS and NDS don't have C++ conformant _stricmp... */ |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
453 #define _stricmp stricmp |
7275
0657179a042c
(svn r10605) -Fix [FS#1046]: also OpenBSD does not know wchar. Patch by Matthias.
rubidium <rubidium@openttd.org>
parents:
7266
diff
changeset
|
454 #elif defined(OPENBSD) |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
455 /* OpenBSD uses strcasecmp(3) */ |
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
456 #define _stricmp strcasecmp |
7275
0657179a042c
(svn r10605) -Fix [FS#1046]: also OpenBSD does not know wchar. Patch by Matthias.
rubidium <rubidium@openttd.org>
parents:
7266
diff
changeset
|
457 #endif |
0657179a042c
(svn r10605) -Fix [FS#1046]: also OpenBSD does not know wchar. Patch by Matthias.
rubidium <rubidium@openttd.org>
parents:
7266
diff
changeset
|
458 |
15149
705c7db7523c
(svn r19778) -Change: use the value from PATH_MAX (POSIX) for MAX_PATH (Windows/OpenTTD) if it exists
rubidium <rubidium@openttd.org>
parents:
15072
diff
changeset
|
459 #if defined(MAX_PATH) |
705c7db7523c
(svn r19778) -Change: use the value from PATH_MAX (POSIX) for MAX_PATH (Windows/OpenTTD) if it exists
rubidium <rubidium@openttd.org>
parents:
15072
diff
changeset
|
460 /* It's already defined, no need to override */ |
705c7db7523c
(svn r19778) -Change: use the value from PATH_MAX (POSIX) for MAX_PATH (Windows/OpenTTD) if it exists
rubidium <rubidium@openttd.org>
parents:
15072
diff
changeset
|
461 #elif defined(PATH_MAX) && PATH_MAX > 0 |
705c7db7523c
(svn r19778) -Change: use the value from PATH_MAX (POSIX) for MAX_PATH (Windows/OpenTTD) if it exists
rubidium <rubidium@openttd.org>
parents:
15072
diff
changeset
|
462 /* Use the value from PATH_MAX, if it exists */ |
705c7db7523c
(svn r19778) -Change: use the value from PATH_MAX (POSIX) for MAX_PATH (Windows/OpenTTD) if it exists
rubidium <rubidium@openttd.org>
parents:
15072
diff
changeset
|
463 #define MAX_PATH PATH_MAX |
705c7db7523c
(svn r19778) -Change: use the value from PATH_MAX (POSIX) for MAX_PATH (Windows/OpenTTD) if it exists
rubidium <rubidium@openttd.org>
parents:
15072
diff
changeset
|
464 #else |
705c7db7523c
(svn r19778) -Change: use the value from PATH_MAX (POSIX) for MAX_PATH (Windows/OpenTTD) if it exists
rubidium <rubidium@openttd.org>
parents:
15072
diff
changeset
|
465 /* If all else fails, hardcode something :( */ |
8004
3624827ca78b
(svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents:
7927
diff
changeset
|
466 #define MAX_PATH 260 |
7266
550b96f71f7f
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium <rubidium@openttd.org>
parents:
7255
diff
changeset
|
467 #endif |
550b96f71f7f
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium <rubidium@openttd.org>
parents:
7255
diff
changeset
|
468 |
8123
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
8051
diff
changeset
|
469 /** |
18362
d7607ed4eef6
(svn r23198) -Codechange: introduce a free that takes const pointers so we don't need to cast to void/non-const before being able to free
rubidium <rubidium@openttd.org>
parents:
18066
diff
changeset
|
470 * Version of the standard free that accepts const pointers. |
d7607ed4eef6
(svn r23198) -Codechange: introduce a free that takes const pointers so we don't need to cast to void/non-const before being able to free
rubidium <rubidium@openttd.org>
parents:
18066
diff
changeset
|
471 * @param ptr The data to free. |
d7607ed4eef6
(svn r23198) -Codechange: introduce a free that takes const pointers so we don't need to cast to void/non-const before being able to free
rubidium <rubidium@openttd.org>
parents:
18066
diff
changeset
|
472 */ |
18792
c99e695378ce
(svn r23640) -Fix: stop using FORCEINLINE (1/3rd of the instances were, the others were still regular inline), but make sure inline is always a 'forced' inline (I am looking at you MSVC)
truebrain <truebrain@openttd.org>
parents:
18740
diff
changeset
|
473 static inline void free(const void *ptr) |
18362
d7607ed4eef6
(svn r23198) -Codechange: introduce a free that takes const pointers so we don't need to cast to void/non-const before being able to free
rubidium <rubidium@openttd.org>
parents:
18066
diff
changeset
|
474 { |
d7607ed4eef6
(svn r23198) -Codechange: introduce a free that takes const pointers so we don't need to cast to void/non-const before being able to free
rubidium <rubidium@openttd.org>
parents:
18066
diff
changeset
|
475 free(const_cast<void *>(ptr)); |
d7607ed4eef6
(svn r23198) -Codechange: introduce a free that takes const pointers so we don't need to cast to void/non-const before being able to free
rubidium <rubidium@openttd.org>
parents:
18066
diff
changeset
|
476 } |
d7607ed4eef6
(svn r23198) -Codechange: introduce a free that takes const pointers so we don't need to cast to void/non-const before being able to free
rubidium <rubidium@openttd.org>
parents:
18066
diff
changeset
|
477 |
d7607ed4eef6
(svn r23198) -Codechange: introduce a free that takes const pointers so we don't need to cast to void/non-const before being able to free
rubidium <rubidium@openttd.org>
parents:
18066
diff
changeset
|
478 /** |
8123
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
8051
diff
changeset
|
479 * The largest value that can be entered in a variable |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
8051
diff
changeset
|
480 * @param type the type of the variable |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
8051
diff
changeset
|
481 */ |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
8051
diff
changeset
|
482 #define MAX_UVALUE(type) ((type)~(type)0) |
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
8051
diff
changeset
|
483 |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
484 #endif /* STDAFX_H */ |