annotate src/stdafx.h @ 12083:8becf4c44755 draft

(svn r16492) -Remove: support for gcc2. It hasn't been able to compile OTTD for months. All attempts to do another workaround failed.
author smatz <smatz@openttd.org>
date Mon, 01 Jun 2009 11:49:46 +0000
parents 86fca539ec7a
children 892bc121d963
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
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
3 /** @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
4
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
5 #ifndef STDAFX_H
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
6 #define STDAFX_H
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
7
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
8 #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
9 #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
10 #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
11
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
12 #if defined(__NDS__)
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
13 #include <nds/jtypes.h>
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
14 /* NDS' types for uint32/int32 are based on longs, which causes
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
15 * trouble all over the place in OpenTTD. */
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
16 #define uint32 uint32_ugly_hack
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
17 #define int32 int32_ugly_hack
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
18 typedef unsigned int uint32_ugly_hack;
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
19 typedef signed int int32_ugly_hack;
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
20 #endif /* __NDS__ */
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
21
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
22 /* 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
23 * We need INT64_MAX, which for most systems comes from stdint.h. However, MSVC
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
24 * does not have stdint.h and apparently neither does MorphOS, so define
7775
315b179cfa8c (svn r11325) -Fix (r11312)[FS#1357]: [OSX] fixed compilation on OSX
bjarni <bjarni@openttd.org>
parents: 7405
diff changeset
25 * INT64_MAX for them ourselves.
315b179cfa8c (svn r11325) -Fix (r11312)[FS#1357]: [OSX] fixed compilation on OSX
bjarni <bjarni@openttd.org>
parents: 7405
diff changeset
26 * Sometimes OSX headers manages to include stdint.h before this but without
315b179cfa8c (svn r11325) -Fix (r11312)[FS#1357]: [OSX] fixed compilation on OSX
bjarni <bjarni@openttd.org>
parents: 7405
diff changeset
27 * __STDC_LIMIT_MACROS so it will be without INT64_*. We need to define those
315b179cfa8c (svn r11325) -Fix (r11312)[FS#1357]: [OSX] fixed compilation on OSX
bjarni <bjarni@openttd.org>
parents: 7405
diff changeset
28 * too if this is the case. */
315b179cfa8c (svn r11325) -Fix (r11312)[FS#1357]: [OSX] fixed compilation on OSX
bjarni <bjarni@openttd.org>
parents: 7405
diff changeset
29 #if !defined(_MSC_VER) && !defined( __MORPHOS__) && !defined(_STDINT_H_)
8004
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
30 #if defined(SUNOS)
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
31 /* 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
32 * 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
33 #include <inttypes.h>
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
34 # else
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
35 #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
36 #include <stdint.h>
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
37 #endif
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
38 #else
8825
1603ed357fcb (svn r12573) -Codechange: use defined constants instead of numbers in math_func.hpp
smatz <smatz@openttd.org>
parents: 8823
diff changeset
39 #define UINT64_MAX (18446744073709551615ULL)
1603ed357fcb (svn r12573) -Codechange: use defined constants instead of numbers in math_func.hpp
smatz <smatz@openttd.org>
parents: 8823
diff changeset
40 #define INT64_MAX (9223372036854775807LL)
1603ed357fcb (svn r12573) -Codechange: use defined constants instead of numbers in math_func.hpp
smatz <smatz@openttd.org>
parents: 8823
diff changeset
41 #define INT64_MIN (-INT64_MAX - 1)
1603ed357fcb (svn r12573) -Codechange: use defined constants instead of numbers in math_func.hpp
smatz <smatz@openttd.org>
parents: 8823
diff changeset
42 #define UINT32_MAX (4294967295U)
1603ed357fcb (svn r12573) -Codechange: use defined constants instead of numbers in math_func.hpp
smatz <smatz@openttd.org>
parents: 8823
diff changeset
43 #define INT32_MAX (2147483647)
1603ed357fcb (svn r12573) -Codechange: use defined constants instead of numbers in math_func.hpp
smatz <smatz@openttd.org>
parents: 8823
diff changeset
44 #define INT32_MIN (-INT32_MAX - 1)
1603ed357fcb (svn r12573) -Codechange: use defined constants instead of numbers in math_func.hpp
smatz <smatz@openttd.org>
parents: 8823
diff changeset
45 #define UINT16_MAX (65535U)
1603ed357fcb (svn r12573) -Codechange: use defined constants instead of numbers in math_func.hpp
smatz <smatz@openttd.org>
parents: 8823
diff changeset
46 #define INT16_MAX (32767)
1603ed357fcb (svn r12573) -Codechange: use defined constants instead of numbers in math_func.hpp
smatz <smatz@openttd.org>
parents: 8823
diff changeset
47 #define INT16_MIN (-INT16_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
48 #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
49
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
50 #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
51 #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
52 #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
53 #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
54 #include <climits>
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
55
5934
3af431a1ae93 (svn r8573) -Cleanup: obey the comment style in stdafx.h.
rubidium <rubidium@openttd.org>
parents: 5933
diff changeset
56 /* MacOS X will use an NSAlert to display failed assertaions since they're lost unless running from a terminal
3af431a1ae93 (svn r8573) -Cleanup: obey the comment style in stdafx.h.
rubidium <rubidium@openttd.org>
parents: 5933
diff changeset
57 * strgen always runs from terminal and don't need a window for asserts */
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
58 #if !defined(__APPLE__) || defined(STRGEN)
8004
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
59 #include <cassert>
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
60 #else
8004
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
61 #include "os/macosx/macos.h"
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
62 #endif
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
63
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
64 #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
65 #include <sys/types.h>
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
66 #endif
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
67
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
68 #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
69 #include <types.h>
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
70 #define strcasecmp stricmp
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
71 #endif
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
72
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
73 #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
74 #include <psptypes.h>
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
75 #include <pspdebug.h>
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
76 #include <pspthreadman.h>
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
77 #endif
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
78
8004
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
79 #if defined(__BEOS__)
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
80 #include <SupportDefs.h>
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
81 #endif
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
82
9072
e197fbb0bbb8 (svn r12930) -Add: build support for NetBSD and HP-UX. Patch by ahoka.
rubidium <rubidium@openttd.org>
parents: 8983
diff changeset
83 #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
84 #include <alloca.h>
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
85 #endif
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
86
8004
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
87 #if defined(__MORPHOS__)
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
88 /* 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
89 * 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
90 * 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
91 #if defined(amigaos)
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
92 #undef amigaos
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
93 #endif
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
94 #if defined(__amigaos__)
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
95 #undef __amigaos__
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
96 # endif
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
97 #if defined(__AMIGA__)
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
98 #undef __AMIGA__
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
99 #endif
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
100 #if defined(AMIGA)
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
101 #undef AMIGA
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
102 #endif
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
103 #if defined(amiga)
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
104 #undef amiga
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
105 #endif
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
106 /* 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
107 * (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
108 #define CLIB_USERGROUP_PROTOS_H
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
109 #endif /* __MORPHOS__ */
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
110
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
111 #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
112 /* 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
113 * 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
114 * 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
115 #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
116 #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
117 #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
118
5934
3af431a1ae93 (svn r8573) -Cleanup: obey the comment style in stdafx.h.
rubidium <rubidium@openttd.org>
parents: 5933
diff changeset
119 /* Stuff for GCC */
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
120 #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
121 #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
122 #define FORCEINLINE inline
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
123 #define CDECL
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
124 #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
125 #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
126 /* 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
127 * 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
128 #define WARN_FORMAT(string, args) __attribute__ ((format (printf, string, args)))
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
129 #endif /* __GNUC__ */
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
130
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
131 #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
132 #define NORETURN
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
133 #define FORCEINLINE inline
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
134 #define CDECL
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
135 #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
136 #define WARN_FORMAT(string, args)
8004
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
137 #include <malloc.h>
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
138 #endif /* __WATCOMC__ */
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
139
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
140 #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
141 #include <malloc.h> // alloca()
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
142 #endif
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
143
9256
8b6ba58e370c (svn r13122) -Fix: WIN32_LEAN_AND_MEAN define is needed for all WIN32 compilers
glx <glx@openttd.org>
parents: 9117
diff changeset
144 #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
145 #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
146 #endif
8b6ba58e370c (svn r13122) -Fix: WIN32_LEAN_AND_MEAN define is needed for all WIN32 compilers
glx <glx@openttd.org>
parents: 9117
diff changeset
147
5934
3af431a1ae93 (svn r8573) -Cleanup: obey the comment style in stdafx.h.
rubidium <rubidium@openttd.org>
parents: 5933
diff changeset
148 /* Stuff for MSVC */
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
149 #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
150 #pragma once
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
151 /* 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
152 * 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
153 #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
154 #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
155 #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
156 #if !defined(WINCE)
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
157 #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
158 #endif
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
159 #define _WIN32_IE_ 0x0401 // 4.01 (win98 and NT4SP5+)
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
160
8004
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
161 #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
162 #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
163 #pragma warning(disable: 4200) // nonstandard extension used : zero-sized array in struct/union
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
164
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
165 #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
166 #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
167 #endif /* (_MSC_VER < 1400) */
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
168 #pragma warning(disable: 4996) // 'strdup' was declared deprecated
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
169 #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
170 #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
171 #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
172 #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
173 #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
174 #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
175 #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 ...
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
176 #define WARN_FORMAT(string, args)
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
177
8004
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
178 #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
179 #define NORETURN __declspec(noreturn)
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
180 #define FORCEINLINE __forceinline
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
181 #define inline _inline
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
182
8004
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
183 #if !defined(WINCE)
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
184 #define CDECL _cdecl
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
185 #endif
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
186
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
187 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
188 #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
189 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
190 #endif
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
191
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
192 #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
193 #if !defined(_W64)
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
194 #define _W64
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
195 #endif
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
196
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
197 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
198 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
199 #endif /* WIN32 && !_WIN64 && !WIN64 */
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
200
9390
45c874394355 (svn r13301) -Fix [FS#1997]: resolve more MSVC 9 x64 warnings.
rubidium <rubidium@openttd.org>
parents: 9256
diff changeset
201 #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
202 #define fseek _fseeki64
45c874394355 (svn r13301) -Fix [FS#1997]: resolve more MSVC 9 x64 warnings.
rubidium <rubidium@openttd.org>
parents: 9256
diff changeset
203 #endif /* _WIN64 || WIN64 */
45c874394355 (svn r13301) -Fix [FS#1997]: resolve more MSVC 9 x64 warnings.
rubidium <rubidium@openttd.org>
parents: 9256
diff changeset
204
45c874394355 (svn r13301) -Fix [FS#1997]: resolve more MSVC 9 x64 warnings.
rubidium <rubidium@openttd.org>
parents: 9256
diff changeset
205
8004
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
206 #define GCC_PACK
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
207
8004
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
208 /* 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
209 #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
210 #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
211 #define ZLIB_WINAPI
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
212 #endif
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
213 #endif
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
214
8004
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
215 #if defined(WINCE)
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
216 #define strcasecmp _stricmp
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
217 #define strncasecmp _strnicmp
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
218 #undef DEBUG
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
219 #else
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
220 #define strcasecmp stricmp
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
221 #define strncasecmp strnicmp
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
222 #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
223
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
224 void SetExceptionString(const char *s, ...) WARN_FORMAT(1, 2);
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
225
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
226 #if defined(NDEBUG) && defined(WITH_ASSERT)
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
227 #undef assert
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
228 #define assert(expression) if (!(expression)) { SetExceptionString("Assertion failed at %s:%d: %s", __FILE__, __LINE__, #expression); *(byte*)0 = 0; }
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
229 #endif
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
230
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
231 /* 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
232 #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
233 #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
234
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
235 #endif /* defined(_MSC_VER) */
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
236
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
237 #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
238 #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
239 #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
240
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
241 /* 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
242 * call to the same function and is not thread- or reentrancy-safe */
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
243 #if !defined(STRGEN)
8004
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
244 #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
245 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
246 #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
247 #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
248
8004
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
249 /* 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
250 #if !defined(WINCE)
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
251 #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
252 #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
253 #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
254
8004
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
255 const char *FS2OTTD(const TCHAR *name);
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
256 const TCHAR *OTTD2FS(const char *name);
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
257 #else
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
258 #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
259 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
260 const char *OTTD2FS(const char *name);
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
261 #endif /* WIN32 */
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
262 #endif /* STRGEN */
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
263
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
264 #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
265 #define PATHSEP "\\"
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
266 #define PATHSEPCHAR '\\'
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
267 #else
8004
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
268 #define PATHSEP "/"
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
269 #define PATHSEPCHAR '/'
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
270 #endif
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
271
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
272 /* 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
273 #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
274 #define OTTD_PRINTF64 "%I64d"
86fca539ec7a (svn r16269) -Codechange: use gcc's ability to check parameters sent to printf-like functions
smatz <smatz@openttd.org>
parents: 11531
diff changeset
275 #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
276 #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
277 #define OTTD_PRINTF64 "%lld"
86fca539ec7a (svn r16269) -Codechange: use gcc's ability to check parameters sent to printf-like functions
smatz <smatz@openttd.org>
parents: 11531
diff changeset
278 #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
279 #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
280
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
281 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
282
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
283 /* This is already defined in unix, but not in QNX Neutrino (6.x)*/
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
284 #if (!defined(UNIX) && !defined(__CYGWIN__) && !defined(__BEOS__) && !defined(__MORPHOS__)) || defined(__QNXNTO__)
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
285 typedef unsigned int uint;
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
286 #endif
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
287
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
288 #if !defined(__BEOS__) && !defined(__NDS__) /* Already defined on BEOS and NDS */
8004
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
289 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
290 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
291 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
292 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
293 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
294 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
295 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
296 typedef signed __int64 int64;
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
297 #endif /* !__BEOS__ && !__NDS__ */
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
298
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
299 #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
300 #define PERSONAL_DIR ""
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
301 #endif
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
302
5934
3af431a1ae93 (svn r8573) -Cleanup: obey the comment style in stdafx.h.
rubidium <rubidium@openttd.org>
parents: 5933
diff changeset
303 /* Compile time assertions */
8004
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
304 #if defined(__OS2__)
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
305 #define assert_compile(expr)
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
306 #else
9117
453c3d26f4bc (svn r12977) -Codechange: remove quite some redundant (duplicate) function declarations.
rubidium <rubidium@openttd.org>
parents: 9111
diff changeset
307 #define assert_compile(expr) extern const int __ct_assert__[1 - 2 * !(expr)]
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
308 #endif /* __OS2__ */
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
309
8678
c662110e3c06 (svn r12344) -Codechange: Check uint64 bitsize on compiletime too.
skidd13 <skidd13@openttd.org>
parents: 8409
diff changeset
310 /* 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
311 assert_compile(sizeof(uint64) == 8);
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
312 assert_compile(sizeof(uint32) == 4);
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
313 assert_compile(sizeof(uint16) == 2);
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
314 assert_compile(sizeof(uint8) == 1);
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
315
10308
7f52d0f68806 (svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents: 9997
diff changeset
316 /**
7f52d0f68806 (svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents: 9997
diff changeset
317 * Return the length of an fixed size array.
7f52d0f68806 (svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents: 9997
diff changeset
318 * 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
319 * of the given type.
7f52d0f68806 (svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents: 9997
diff changeset
320 *
7f52d0f68806 (svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents: 9997
diff changeset
321 * @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
322 * @return The number of elements
7f52d0f68806 (svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents: 9997
diff changeset
323 */
9117
453c3d26f4bc (svn r12977) -Codechange: remove quite some redundant (duplicate) function declarations.
rubidium <rubidium@openttd.org>
parents: 9111
diff changeset
324 #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
325
7f52d0f68806 (svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents: 9997
diff changeset
326 /**
7f52d0f68806 (svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents: 9997
diff changeset
327 * 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
328 *
7f52d0f68806 (svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents: 9997
diff changeset
329 * @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
330 * @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
331 */
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
332 #define endof(x) (&x[lengthof(x)])
10308
7f52d0f68806 (svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents: 9997
diff changeset
333
7f52d0f68806 (svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents: 9997
diff changeset
334 /**
7f52d0f68806 (svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents: 9997
diff changeset
335 * 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
336 *
7f52d0f68806 (svn r14553) -Doc: Add some doxygen comments
skidd13 <skidd13@openttd.org>
parents: 9997
diff changeset
337 * @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
338 * @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
339 */
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
340 #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
341
8969
01cc3ee6ecb1 (svn r12761) -Codechange: lots of minor whitespace coding style fixes around operators.
rubidium <rubidium@openttd.org>
parents: 8825
diff changeset
342 #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
343 #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
344 #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
345 #endif /* offsetof */
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
346
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
347
5934
3af431a1ae93 (svn r8573) -Cleanup: obey the comment style in stdafx.h.
rubidium <rubidium@openttd.org>
parents: 5933
diff changeset
348 /* 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
349 #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
350 #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
351 #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
352 #define CloseConnection OTTD_CloseConnection
8126
357c22303fd6 (svn r11687) -Codechange: move some defines to a better place
skidd13 <skidd13@openttd.org>
parents: 8123
diff changeset
353 #endif /* __APPLE__ */
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
354
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
355 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
356 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
357 #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
358
10385
9709c41adf56 (svn r14636) -Add: DOS port of OpenTTD, without network support though.
rubidium <rubidium@openttd.org>
parents: 10384
diff changeset
359 #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
360 /* 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
361 #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
362 #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
363 /* 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
364 #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
365 #endif
0657179a042c (svn r10605) -Fix [FS#1046]: also OpenBSD does not know wchar. Patch by Matthias.
rubidium <rubidium@openttd.org>
parents: 7266
diff changeset
366
10385
9709c41adf56 (svn r14636) -Add: DOS port of OpenTTD, without network support though.
rubidium <rubidium@openttd.org>
parents: 10384
diff changeset
367 #if !defined(MORPHOS) && !defined(OPENBSD) && !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
368 /* NDS, MorphOS & OpenBSD don't know wchars, the rest does :( */
8004
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
369 #define HAS_WCHAR
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
370 #endif /* !defined(MORPHOS) && !defined(OPENBSD) && !defined(__NDS__) */
7255
8ab9b7eee23a (svn r10562) -Fix: most of the MorphOS issues; MorphOS doesn't know about wchars, so disable all code that has to use wchars for MorphOS.
rubidium <rubidium@openttd.org>
parents: 7154
diff changeset
371
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
372 #if !defined(MAX_PATH)
8004
3624827ca78b (svn r11563) -Codechange: Align the preprocessor code in stdafx.h with tabs
skidd13 <skidd13@openttd.org>
parents: 7927
diff changeset
373 #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
374 #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
375
8123
c26c28875749 (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents: 8051
diff changeset
376 /**
c26c28875749 (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents: 8051
diff changeset
377 * 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
378 * @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
379 */
c26c28875749 (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents: 8051
diff changeset
380 #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
381
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
382 #endif /* STDAFX_H */