OSDN Git Service

./bootstrap 実行時に warning が出ないよう修正。
[hengband/hengband.git] / src / h-type.h
1 /* File: h-type.h */
2
3 #ifndef INCLUDED_H_TYPE_H
4 #define INCLUDED_H_TYPE_H
5
6 /*
7  * Basic "types".
8  *
9  * Note the attempt to make all basic types have 4 letters.
10  * This improves readibility and standardizes the code.
11  *
12  * Likewise, all complex types are at least 4 letters.
13  * Thus, almost every three letter word is a legal variable.
14  * But beware of certain reserved words ('for' and 'if' and 'do').
15  *
16  * Note that the type used in structures for bit flags should be uint.
17  * As long as these bit flags are sequential, they will be space smart.
18  *
19  * Note that on some machines, apparently "signed char" is illegal.
20  *
21  * It must be true that char/byte takes exactly 1 byte
22  * It must be true that sind/uind takes exactly 2 bytes
23  * It must be true that sbig/ubig takes exactly 4 bytes
24  *
25  * On Sparc's, a sint takes 4 bytes (2 is legal)
26  * On Sparc's, a uint takes 4 bytes (2 is legal)
27  * On Sparc's, a long takes 4 bytes (8 is legal)
28  * On Sparc's, a huge takes 4 bytes (8 is legal)
29  * On Sparc's, a vptr takes 4 bytes (8 is legal)
30  * On Sparc's, a real takes 8 bytes (4 is legal)
31  *
32  * Note that some files have already been included by "h-include.h"
33  * These include <stdio.h> and <sys/types>, which define some types
34  * In particular, uint is defined so we do not have to define it
35  *
36  * Also, see <limits.h> for min/max values for sind, uind, long, huge
37  * (SHRT_MIN, SHRT_MAX, USHRT_MAX, LONG_MIN, LONG_MAX, ULONG_MAX)
38  * These limits should be verified and coded into "h-constant.h".
39  */
40
41
42
43 /*** Special 4 letter names for some standard types ***/
44
45
46 /* A standard pointer (to "void" because ANSI C says so) */
47 typedef void *vptr;
48
49 /* A simple pointer (to unmodifiable strings) */
50 typedef const char *cptr;
51
52
53 /* Since float's are silly, hard code real numbers as doubles */
54 typedef double real;
55
56
57 /* Error codes for function return values */
58 /* Success = 0, Failure = -N, Problem = +N */
59 typedef int errr;
60
61
62 /*
63  * Hack -- prevent problems with non-MACINTOSH
64  */
65 #undef uint
66 #define uint uint_hack
67
68 /*
69  * Hack -- prevent problems with MSDOS and WINDOWS
70  */
71 #undef huge
72 #define huge huge_hack
73
74 /*
75  * Hack -- prevent problems with AMIGA
76  */
77 #undef byte
78 #define byte byte_hack
79
80 /*
81  * Hack -- prevent problems with C++
82  */
83 #undef bool
84 #define bool bool_hack
85
86
87 /* Note that "signed char" is not always "defined" */
88 /* So always use "s16b" to hold small signed values */
89 /* A signed byte of memory */
90 /* typedef signed char syte; */
91
92 /* Note that unsigned values can cause math problems */
93 /* An unsigned byte of memory */
94 typedef unsigned char byte;
95
96 /* Note that a bool is smaller than a full "int" */
97 /* Simple True/False type */
98 typedef char bool;
99
100
101 /* A signed, standard integer (at least 2 bytes) */
102 typedef int sint;
103
104 /* An unsigned, "standard" integer (often pre-defined) */
105 typedef unsigned int uint;
106
107
108 /* The largest possible signed integer (pre-defined) */
109 /* typedef long long; */
110
111 /* The largest possible unsigned integer */
112 typedef unsigned long huge;
113
114
115 /* Signed/Unsigned 16 bit value */
116 typedef signed short s16b;
117 typedef unsigned short u16b;
118
119 /* Signed/Unsigned 32 bit value */
120 #ifdef L64      /* 64 bit longs */
121 typedef signed int s32b;
122 typedef unsigned int u32b;
123 #else
124 typedef signed long s32b;
125 typedef unsigned long u32b;
126 #endif
127
128
129
130
131 /*** Pointers to all the basic types defined above ***/
132
133 typedef real *real_ptr;
134 typedef errr *errr_ptr;
135 typedef char *char_ptr;
136 typedef byte *byte_ptr;
137 typedef bool *bool_ptr;
138 typedef sint *sint_ptr;
139 typedef uint *uint_ptr;
140 typedef long *long_ptr;
141 typedef huge *huge_ptr;
142 typedef s16b *s16b_ptr;
143 typedef u16b *u16b_ptr;
144 typedef s32b *s32b_ptr;
145 typedef u32b *u32b_ptr;
146 typedef vptr *vptr_ptr;
147 typedef cptr *cptr_ptr;
148
149
150
151 /*** Pointers to Functions of special types (for various purposes) ***/
152
153 /* A generic function takes a user data and a special data */
154 typedef errr    (*func_gen)(vptr, vptr);
155
156 /* An equality testing function takes two things to compare (bool) */
157 typedef bool    (*func_eql)(vptr, vptr);
158
159 /* A comparison function takes two things and to compare (-1,0,+1) */
160 typedef sint    (*func_cmp)(vptr, vptr);
161
162 /* A hasher takes a thing (and a max hash size) to hash (0 to siz - 1) */
163 typedef uint    (*func_hsh)(vptr, uint);
164
165 /* A key extractor takes a thing and returns (a pointer to) some key */
166 typedef vptr    (*func_key)(vptr);
167
168
169
170 #endif
171