src/stdafx.h
author richk
Fri, 18 Apr 2008 19:55:13 +0000
branchNewGRF_ports
changeset 10242 52b4a9006029
parent 10184 fcf5fb2548eb
child 10274 b3c58f3df92b
permissions -rw-r--r--
(svn r12774) [NewGRF_ports] -Sync: with trunk r12742:12772.
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2125
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2125
diff changeset
     2
6719
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6611
diff changeset
     3
/** @file stdafx.h */
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6611
diff changeset
     4
2436
177cb6a8339f (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2225
diff changeset
     5
#ifndef STDAFX_H
177cb6a8339f (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2225
diff changeset
     6
#define STDAFX_H
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     7
6872
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
     8
#if defined(__NDS__)
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
     9
	#include <nds/jtypes.h>
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    10
	/* NDS' types for uint32/int32 are based on longs, which causes
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    11
	 * trouble all over the place in OpenTTD. */
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    12
	#define uint32 uint32_ugly_hack
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    13
	#define int32 int32_ugly_hack
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    14
	typedef unsigned int uint32_ugly_hack;
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    15
	typedef signed int int32_ugly_hack;
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    16
#endif /* __NDS__ */
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    17
6071
c37b45d0109b (svn r8382) -Fix (r8374): moved the include of stdint.h to the front of stdafx.h
bjarni
parents: 6063
diff changeset
    18
/* It seems that we need to include stdint.h before anything else
c37b45d0109b (svn r8382) -Fix (r8374): moved the include of stdint.h to the front of stdafx.h
bjarni
parents: 6063
diff changeset
    19
 * We need INT64_MAX, which for most systems comes from stdint.h. However, MSVC
c37b45d0109b (svn r8382) -Fix (r8374): moved the include of stdint.h to the front of stdafx.h
bjarni
parents: 6063
diff changeset
    20
 * does not have stdint.h and apparently neither does MorphOS, so define
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    21
 * INT64_MAX for them ourselves.
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    22
 * Sometimes OSX headers manages to include stdint.h before this but without
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    23
 * __STDC_LIMIT_MACROS so it will be without INT64_*. We need to define those
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    24
 * too if this is the case. */
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    25
#if !defined(_MSC_VER) && !defined( __MORPHOS__) && !defined(_STDINT_H_)
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    26
	#if defined(SUNOS)
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    27
		/* SunOS/Solaris does not have stdint.h, but inttypes.h defines everything
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    28
		 * stdint.h defines and we need. */
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    29
		#include <inttypes.h>
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    30
	# else
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    31
		#define __STDC_LIMIT_MACROS
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    32
		#include <stdint.h>
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    33
	#endif
6071
c37b45d0109b (svn r8382) -Fix (r8374): moved the include of stdint.h to the front of stdafx.h
bjarni
parents: 6063
diff changeset
    34
#else
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
    35
	#define UINT64_MAX (18446744073709551615ULL)
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
    36
	#define INT64_MAX  (9223372036854775807LL)
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
    37
	#define INT64_MIN  (-INT64_MAX - 1)
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
    38
	#define UINT32_MAX (4294967295U)
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
    39
	#define INT32_MAX  (2147483647)
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
    40
	#define INT32_MIN  (-INT32_MAX - 1)
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
    41
	#define UINT16_MAX (65535U)
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
    42
	#define INT16_MAX  (32767)
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
    43
	#define INT16_MIN  (-INT16_MAX - 1)
6071
c37b45d0109b (svn r8382) -Fix (r8374): moved the include of stdint.h to the front of stdafx.h
bjarni
parents: 6063
diff changeset
    44
#endif
c37b45d0109b (svn r8382) -Fix (r8374): moved the include of stdint.h to the front of stdafx.h
bjarni
parents: 6063
diff changeset
    45
6184
3cfe1dfa7a04 (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
parents: 6094
diff changeset
    46
#include <cstdio>
3cfe1dfa7a04 (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
parents: 6094
diff changeset
    47
#include <cstddef>
3cfe1dfa7a04 (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
parents: 6094
diff changeset
    48
#include <cstring>
3cfe1dfa7a04 (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
parents: 6094
diff changeset
    49
#include <cstdlib>
3cfe1dfa7a04 (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
parents: 6094
diff changeset
    50
#include <climits>
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    51
6185
be6627364fa3 (svn r8573) -Cleanup: obey the comment style in stdafx.h.
rubidium
parents: 6184
diff changeset
    52
/* MacOS X will use an NSAlert to display failed assertaions since they're lost unless running from a terminal
be6627364fa3 (svn r8573) -Cleanup: obey the comment style in stdafx.h.
rubidium
parents: 6184
diff changeset
    53
 * strgen always runs from terminal and don't need a window for asserts */
2731
97a409a62741 (svn r3276) reverted the last two commits. OSX 10.2 kept finding new stuff to prevent it from running OpenTTD, so now it's not supported anymore
bjarni
parents: 2730
diff changeset
    54
#if !defined(__APPLE__) || defined(STRGEN)
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    55
	#include <cassert>
2223
29d61b962cb0 (svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents: 2186
diff changeset
    56
#else
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    57
	#include "os/macosx/macos.h"
2223
29d61b962cb0 (svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents: 2186
diff changeset
    58
#endif
29d61b962cb0 (svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents: 2186
diff changeset
    59
858
329ff519fb45 (svn r1339) -Fix: compilation with networking works on MinGW32 again (thx orudge).
darkvater
parents: 796
diff changeset
    60
#if defined(UNIX) || defined(__MINGW32__)
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    61
	#include <sys/types.h>
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    62
#endif
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    63
781
9717ff353c17 (svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents: 770
diff changeset
    64
#if defined(__OS2__)
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    65
	#include <types.h>
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    66
	#define strcasecmp stricmp
781
9717ff353c17 (svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents: 770
diff changeset
    67
#endif
9717ff353c17 (svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents: 770
diff changeset
    68
6227
ab74f5faf662 (svn r8674) [PSP] -Add: added network code for PSP, based on the work of Turulo
truelight
parents: 6218
diff changeset
    69
#if defined(PSP)
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    70
	#include <psptypes.h>
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    71
	#include <pspdebug.h>
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    72
	#include <pspthreadman.h>
446
20304ea8e94e (svn r655) Add the necessary bits to make building on SunOS/Solaris work
tron
parents: 425
diff changeset
    73
#endif
20304ea8e94e (svn r655) Add the necessary bits to make building on SunOS/Solaris work
tron
parents: 425
diff changeset
    74
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    75
#if defined(__BEOS__)
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    76
	#include <SupportDefs.h>
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    77
#endif
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    78
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    79
#if defined(SUNOS)
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    80
	#include <alloca.h>
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    81
#endif
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    82
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    83
#if defined(__MORPHOS__)
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    84
	/* MorphOS defines certain Amiga defines per default, we undefine them
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    85
	 * here to make the rest of source less messy and more clear what is
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    86
	 * required for morphos and what for AmigaOS */
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    87
	#if defined(amigaos)
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    88
		#undef amigaos
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    89
	#endif
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    90
	#if defined(__amigaos__)
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    91
		#undef __amigaos__
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    92
	# endif
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    93
	#if defined(__AMIGA__)
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    94
		#undef __AMIGA__
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    95
	#endif
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    96
	#if defined(AMIGA)
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    97
		#undef AMIGA
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    98
	#endif
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
    99
	#if defined(amiga)
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   100
		#undef amiga
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   101
	#endif
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   102
	/* Act like we already included this file, as it somehow gives linkage problems
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   103
	 *  (mismatch linkage of C++ and C between this include and unistd.h). */
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   104
	#define CLIB_USERGROUP_PROTOS_H
770
89dab23f04ca (svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents: 569
diff changeset
   105
#endif /* __MORPHOS__ */
89dab23f04ca (svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents: 569
diff changeset
   106
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   107
#if defined(__APPLE__)
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   108
	#include "os/macosx/osx_stdafx.h"
3289
8c0707257253 (svn r4003) - Minor codebeautifier@work
Darkvater
parents: 3016
diff changeset
   109
#endif /* __APPLE__ */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   110
6218
89dc931b8d78 (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
parents: 6198
diff changeset
   111
#if defined(PSP)
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   112
	/* PSP can only have 10 file-descriptors open at any given time, but this
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   113
	 *  switch only limits reads via the Fio system. So keep 2 fds free for things
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   114
	 *  like saving a game. */
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   115
	#define LIMITED_FDS 8
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   116
	#define printf pspDebugScreenPrintf
6218
89dc931b8d78 (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
parents: 6198
diff changeset
   117
#endif /* PSP */
89dc931b8d78 (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
parents: 6198
diff changeset
   118
6185
be6627364fa3 (svn r8573) -Cleanup: obey the comment style in stdafx.h.
rubidium
parents: 6184
diff changeset
   119
/* by default we use [] var arrays */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   120
#define VARARRAY_SIZE
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   121
6185
be6627364fa3 (svn r8573) -Cleanup: obey the comment style in stdafx.h.
rubidium
parents: 6184
diff changeset
   122
/* Stuff for GCC */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   123
#if defined(__GNUC__)
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   124
	#define NORETURN __attribute__ ((noreturn))
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   125
	#define FORCEINLINE inline
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   126
	#define CDECL
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   127
	#define __int64 long long
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   128
	#define GCC_PACK __attribute__((packed))
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   129
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   130
	#if (__GNUC__ == 2)
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   131
		#undef VARARRAY_SIZE
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   132
		#define VARARRAY_SIZE 0
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   133
	#endif
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   134
#endif /* __GNUC__ */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   135
781
9717ff353c17 (svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents: 770
diff changeset
   136
#if defined(__WATCOMC__)
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   137
	#define NORETURN
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   138
	#define FORCEINLINE inline
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   139
	#define CDECL
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   140
	#define GCC_PACK
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   141
	#include <malloc.h>
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   142
#endif /* __WATCOMC__ */
781
9717ff353c17 (svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents: 770
diff changeset
   143
796
42a3669a939f (svn r1266) -Fix: fix some cygwin/mingw warnings
darkvater
parents: 781
diff changeset
   144
#if defined(__MINGW32__) || defined(__CYGWIN__)
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   145
	#include <malloc.h> // alloca()
796
42a3669a939f (svn r1266) -Fix: fix some cygwin/mingw warnings
darkvater
parents: 781
diff changeset
   146
#endif
42a3669a939f (svn r1266) -Fix: fix some cygwin/mingw warnings
darkvater
parents: 781
diff changeset
   147
6185
be6627364fa3 (svn r8573) -Cleanup: obey the comment style in stdafx.h.
rubidium
parents: 6184
diff changeset
   148
/* Stuff for MSVC */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   149
#if defined(_MSC_VER)
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   150
	#pragma once
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   151
	/* Define a win32 target platform, to override defaults of the SDK
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   152
	 * We need to define NTDDI version for Vista SDK, but win2k is minimum */
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   153
	#define NTDDI_VERSION NTDDI_WIN2K // Windows 2000
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   154
	#define _WIN32_WINNT 0x0500       // Windows 2000
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   155
	#define _WIN32_WINDOWS 0x400      // Windows 95
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   156
	#if !defined(WINCE)
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   157
		#define WINVER 0x0400     // Windows NT 4.0 / Windows 95
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   158
	#endif
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   159
	#define _WIN32_IE_ 0x0401         // 4.01 (win98 and NT4SP5+)
2695
395110265c87 (svn r3237) - CodeChange: remove silencing of some warnings. MSVC6 once again has some issues with enums, and other things as usual, so silence those still.
Darkvater
parents: 2694
diff changeset
   160
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   161
	#define WIN32_LEAN_AND_MEAN     // Exclude rarely-used stuff from Windows headers
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   162
	#pragma warning(disable: 4244)  // 'conversion' conversion from 'type1' to 'type2', possible loss of data
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   163
	#pragma warning(disable: 4761)  // integral size mismatch in argument : conversion supplied
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   164
	#pragma warning(disable: 4200)  // nonstandard extension used : zero-sized array in struct/union
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   165
6877
889301acc299 (svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents: 6872
diff changeset
   166
	#if (_MSC_VER < 1400)                   // MSVC 2005 safety checks
889301acc299 (svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents: 6872
diff changeset
   167
		#error "Only MSVC 2005 or higher are supported. MSVC 2003 and earlier are not!. Upgrade your compiler."
889301acc299 (svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents: 6872
diff changeset
   168
	#endif /* (_MSC_VER < 1400) */
889301acc299 (svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents: 6872
diff changeset
   169
	#pragma warning(disable: 4996)   // 'strdup' was declared deprecated
889301acc299 (svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents: 6872
diff changeset
   170
	#define _CRT_SECURE_NO_DEPRECATE // all deprecated 'unsafe string functions
889301acc299 (svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents: 6872
diff changeset
   171
	#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
889301acc299 (svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents: 6872
diff changeset
   172
	#pragma warning(disable: 6011)   // code analyzer: Dereferencing NULL pointer 'pfGetAddrInfo': Lines: 995, 996, 998, 999, 1001
889301acc299 (svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents: 6872
diff changeset
   173
	#pragma warning(disable: 6326)   // code analyzer: potential comparison of a constant with another constant
889301acc299 (svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents: 6872
diff changeset
   174
	#pragma warning(disable: 6031)   // code analyzer: Return value ignored: 'ReadFile'
889301acc299 (svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents: 6872
diff changeset
   175
	#pragma warning(disable: 6255)   // code analyzer: _alloca indicates failure by raising a stack overflow exception. Consider using _malloca instead
889301acc299 (svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents: 6872
diff changeset
   176
	#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 ...
2694
99d88a9d5337 (svn r3236) - Fix: warnings about 'CDECL must be used with ...' on VS6
Darkvater
parents: 2639
diff changeset
   177
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   178
	#include <malloc.h> // alloca()
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   179
	#define NORETURN __declspec(noreturn)
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   180
	#define FORCEINLINE __forceinline
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   181
	#define inline _inline
2694
99d88a9d5337 (svn r3236) - Fix: warnings about 'CDECL must be used with ...' on VS6
Darkvater
parents: 2639
diff changeset
   182
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   183
	#if !defined(WINCE)
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   184
		#define CDECL _cdecl
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   185
	#endif
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   186
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   187
	int CDECL snprintf(char *str, size_t size, const char *format, ...);
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   188
	#if (_MSC_VER < 1400) || defined(WINCE)
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   189
		int CDECL vsnprintf(char *str, size_t size, const char *format, va_list ap);
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   190
	#endif
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   191
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   192
	#if defined(WIN32) && !defined(_WIN64) && !defined(WIN64)
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   193
		#if !defined(_W64)
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   194
			#define _W64
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   195
		#endif
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   196
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   197
		typedef _W64 int INT_PTR, *PINT_PTR;
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   198
		typedef _W64 unsigned int UINT_PTR, *PUINT_PTR;
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   199
	#endif /* WIN32 && !_WIN64 && !WIN64 */
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   200
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   201
	#define GCC_PACK
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   202
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   203
	/* This is needed to zlib uses the stdcall calling convention on visual studio */
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   204
	#if defined(WITH_ZLIB) || defined(WITH_PNG)
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   205
		#if !defined(ZLIB_WINAPI)
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   206
			#define ZLIB_WINAPI
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   207
		#endif
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   208
	#endif
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   209
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   210
	#if defined(WINCE)
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   211
		#define strcasecmp _stricmp
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   212
		#define strncasecmp _strnicmp
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   213
		#undef DEBUG
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   214
	#else
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   215
		#define strcasecmp stricmp
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   216
		#define strncasecmp strnicmp
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   217
	#endif
6872
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
   218
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
   219
	void SetExceptionString(const char* s, ...);
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
   220
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
   221
	#if defined(NDEBUG) && defined(WITH_ASSERT)
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
   222
		#undef assert
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
   223
		#define assert(expression) if (!(expression)) { SetExceptionString("Assertion failed at %s:%d: %s", __FILE__, __LINE__, #expression); *(byte*)0 = 0; }
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
   224
	#endif
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   225
#endif /* defined(_MSC_VER) */
2483
ee0517ddfa92 (svn r3009) DIEEEEEEEEEEE VS6 (you good-for-nothing compiler)
Darkvater
parents: 2482
diff changeset
   226
6006
56ccbc3ec899 (svn r8306) [WinCE] -Fix: some functions don't exists in WinCE, so give an alternative where possible
truelight
parents: 5922
diff changeset
   227
#if defined(WINCE)
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   228
	#define strdup _strdup
6006
56ccbc3ec899 (svn r8306) [WinCE] -Fix: some functions don't exists in WinCE, so give an alternative where possible
truelight
parents: 5922
diff changeset
   229
#endif /* WINCE */
56ccbc3ec899 (svn r8306) [WinCE] -Fix: some functions don't exists in WinCE, so give an alternative where possible
truelight
parents: 5922
diff changeset
   230
5167
2b9d61386688 (svn r7274) -Codechange [utf8]: Add input/output unicode support. This actually only changes win32
Darkvater
parents: 5138
diff changeset
   231
/* NOTE: the string returned by these functions is only valid until the next
2b9d61386688 (svn r7274) -Codechange [utf8]: Add input/output unicode support. This actually only changes win32
Darkvater
parents: 5138
diff changeset
   232
 * call to the same function and is not thread- or reentrancy-safe */
2b9d61386688 (svn r7274) -Codechange [utf8]: Add input/output unicode support. This actually only changes win32
Darkvater
parents: 5138
diff changeset
   233
#if !defined(STRGEN)
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   234
	#if defined(WIN32) || defined(WIN64)
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   235
		char *getcwd(char *buf, size_t size);
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   236
		#include <tchar.h>
6577
ee768d653dd0 (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
parents: 6559
diff changeset
   237
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   238
		/* XXX - WinCE without MSVCRT doesn't support wfopen, so it seems */
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   239
		#if !defined(WINCE)
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   240
			#define fopen(file, mode) _tfopen(OTTD2FS(file), _T(mode))
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   241
		#endif /* WINCE */
6577
ee768d653dd0 (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
parents: 6559
diff changeset
   242
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   243
		const char *FS2OTTD(const TCHAR *name);
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   244
		const TCHAR *OTTD2FS(const char *name);
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   245
	#else
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   246
		#define fopen(file, mode) fopen(OTTD2FS(file), mode)
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   247
		const char *FS2OTTD(const char *name);
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   248
		const char *OTTD2FS(const char *name);
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   249
	#endif /* WIN32 */
5167
2b9d61386688 (svn r7274) -Codechange [utf8]: Add input/output unicode support. This actually only changes win32
Darkvater
parents: 5138
diff changeset
   250
#endif /* STRGEN */
2482
dffcca243dbc (svn r3008) [ 1247535 ] Native Support for Win64 (compile&run only) (michi_cc)
Darkvater
parents: 2436
diff changeset
   251
5842
180c71b8fc14 (svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents: 5838
diff changeset
   252
#if defined(WIN32) || defined(WIN64) || defined(__OS2__) && !defined(__INNOTEK_LIBC__)
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   253
	#define PATHSEP "\\"
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   254
	#define PATHSEPCHAR '\\'
4379
2866185c1377 (svn r6117) -Fix r6097: on mingw it is normal that both / as \ are accepted as input
truelight
parents: 4316
diff changeset
   255
#else
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   256
	#define PATHSEP "/"
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   257
	#define PATHSEPCHAR '/'
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   258
#endif
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   259
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   260
typedef unsigned char byte;
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   261
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   262
/* This is already defined in unix, but not in QNX Neutrino (6.x)*/
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   263
#if (!defined(UNIX) && !defined(__CYGWIN__) && !defined(__BEOS__) && !defined(__MORPHOS__)) || defined(__QNXNTO__)
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   264
	typedef unsigned int uint;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   265
#endif
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   266
6872
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
   267
#if !defined(__BEOS__) && !defined(__NDS__) /* Already defined on BEOS and NDS */
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   268
	typedef unsigned char    uint8;
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   269
	typedef   signed char     int8;
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   270
	typedef unsigned short   uint16;
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   271
	typedef   signed short    int16;
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   272
	typedef unsigned int     uint32;
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   273
	typedef   signed int      int32;
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   274
	typedef unsigned __int64 uint64;
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   275
	typedef   signed __int64  int64;
6872
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
   276
#endif /* !__BEOS__ && !__NDS__ */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   277
6720
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
   278
#if !defined(WITH_PERSONAL_DIR)
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   279
	#define PERSONAL_DIR ""
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   280
#endif
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   281
6185
be6627364fa3 (svn r8573) -Cleanup: obey the comment style in stdafx.h.
rubidium
parents: 6184
diff changeset
   282
/* Compile time assertions */
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   283
#if defined(__OS2__)
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   284
	#define assert_compile(expr)
781
9717ff353c17 (svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents: 770
diff changeset
   285
#else
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   286
	#define assert_compile(expr) extern "C" void __ct_assert__(int a[1 - 2 * !(expr)])
3900
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3624
diff changeset
   287
#endif /* __OS2__ */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   288
6878
7d1ff2f621c7 (svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents: 6877
diff changeset
   289
/* Check if the types have the bitsizes like we are using them */
7d1ff2f621c7 (svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents: 6877
diff changeset
   290
assert_compile(sizeof(uint64) == 8);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   291
assert_compile(sizeof(uint32) == 4);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   292
assert_compile(sizeof(uint16) == 2);
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2485
diff changeset
   293
assert_compile(sizeof(uint8)  == 1);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   294
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   295
#define lengthof(x) (sizeof(x)/sizeof(x[0]))
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   296
#define endof(x) (&x[lengthof(x)])
1317
f382f1b439c7 (svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents: 1022
diff changeset
   297
#define lastof(x) (&x[lengthof(x) - 1])
5922
510e1bbc5992 (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
parents: 5842
diff changeset
   298
10242
52b4a9006029 (svn r12774) [NewGRF_ports] -Sync: with trunk r12742:12772.
richk
parents: 10184
diff changeset
   299
#define cpp_offsetof(s, m)   (((size_t)&reinterpret_cast<const volatile char&>((((s*)(char*)8)->m))) - 8)
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   300
#if !defined(offsetof)
10242
52b4a9006029 (svn r12774) [NewGRF_ports] -Sync: with trunk r12742:12772.
richk
parents: 10184
diff changeset
   301
	#define offsetof(s, m) cpp_offsetof(s, m)
6409
55217fea8342 (svn r8818) -Codechange: remove the #ifdef _cplusplus remnants.
rubidium
parents: 6227
diff changeset
   302
#endif /* offsetof */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   303
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   304
6185
be6627364fa3 (svn r8573) -Cleanup: obey the comment style in stdafx.h.
rubidium
parents: 6184
diff changeset
   305
/* take care of some name clashes on MacOS */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   306
#if defined(__APPLE__)
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   307
	#define GetString OTTD_GetString
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   308
	#define DrawString OTTD_DrawString
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   309
	#define CloseConnection OTTD_CloseConnection
6872
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
   310
#endif /* __APPLE__ */
569
2e86ae517874 (svn r980) Fixed issues where MorphOS would get problems if AmigaOS would get a port, since MorphOS also have the flag __AMIGA__ defined (Tokai)
bjarni
parents: 543
diff changeset
   311
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   312
#if !defined(STRGEN)
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   313
	/* In strgen error is not fatal and returns */
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   314
	void NORETURN CDECL error(const char *str, ...);
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   315
#else
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   316
	void CDECL error(const char *str, ...);
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   317
#endif
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   318
6719
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6611
diff changeset
   319
#define NOT_REACHED() error("NOT_REACHED triggered at line %i of %s", __LINE__, __FILE__)
4cc327ad39d5 (svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents: 6611
diff changeset
   320
6872
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
   321
#if defined(MORPHOS) || defined(__NDS__)
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
   322
	/* MorphOS and NDS don't have C++ conformant _stricmp... */
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   323
	#define _stricmp stricmp
6732
ca1b466db422 (svn r10653) [NewGRF_ports] -Sync: with trunk r10602-10651
richk
parents: 6725
diff changeset
   324
#elif defined(OPENBSD)
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   325
	/* OpenBSD uses strcasecmp(3) */
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   326
	#define _stricmp strcasecmp
6732
ca1b466db422 (svn r10653) [NewGRF_ports] -Sync: with trunk r10602-10651
richk
parents: 6725
diff changeset
   327
#endif
ca1b466db422 (svn r10653) [NewGRF_ports] -Sync: with trunk r10602-10651
richk
parents: 6725
diff changeset
   328
6872
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
   329
#if !defined(MORPHOS) && !defined(OPENBSD) && !defined(__NDS__)
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
   330
	/* NDS, MorphOS & OpenBSD don't know wchars, the rest does :( */
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   331
	#define HAS_WCHAR
6872
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
   332
#endif /* !defined(MORPHOS) && !defined(OPENBSD) && !defined(__NDS__) */
6725
23339968083f (svn r10595) [NewGRF_ports] -Sync: with trunk r10559-10593
richk
parents: 6720
diff changeset
   333
23339968083f (svn r10595) [NewGRF_ports] -Sync: with trunk r10559-10593
richk
parents: 6720
diff changeset
   334
#if !defined(MAX_PATH)
6871
5a9dc001e1ad (svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents: 6800
diff changeset
   335
	#define MAX_PATH 260
6725
23339968083f (svn r10595) [NewGRF_ports] -Sync: with trunk r10559-10593
richk
parents: 6720
diff changeset
   336
#endif
23339968083f (svn r10595) [NewGRF_ports] -Sync: with trunk r10559-10593
richk
parents: 6720
diff changeset
   337
6872
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
   338
/**
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
   339
 * The largest value that can be entered in a variable
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
   340
 * @param type the type of the variable
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
   341
 */
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
   342
#define MAX_UVALUE(type) ((type)~(type)0)
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
   343
2436
177cb6a8339f (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2225
diff changeset
   344
#endif /* STDAFX_H */