OSDN Git Service

[Fix] #38997 前回マージ後の英語版ビルドエラーを修正. / Fixed English build error after previous merge.
[hengband/hengband.git] / src / h-define.h
1 /*!
2  * @file h-define.h
3  * @brief 変愚蛮怒で新しく追加された主要なマクロ定義ヘッダ / Define some simple constants
4  * @date 2014/08/16
5  * @author
6  * 不明(変愚蛮怒開発チーム?)
7  */
8
9 #ifndef INCLUDED_H_DEFINE_H
10 #define INCLUDED_H_DEFINE_H
11
12
13 /*
14  * Hack -- assist "main-acn.c" 
15  */
16 #ifdef ACORN
17 # define O_RDONLY       0
18 # define O_WRONLY       1
19 # define O_RDWR         2
20 #endif
21
22
23 /*
24  * The constants "TRUE" and "FALSE"
25  */
26
27 #undef TRUE
28 #define TRUE    1 /*!< コンパイル環境に定義がない場合のTRUE定義 */
29
30 #undef FALSE
31 #define FALSE   0 /*!< コンパイル環境に定義がない場合のFALSE定義 */
32
33
34
35
36 /**** Simple "Macros" ****/
37
38 #ifdef ZANGBAND_JP
39 #define lbtokg(x) ((int)(((x)*4536)/1000)) /*!< Zangband基準のポンド→キログラム変換定義(全体) */
40 #define lbtokg1(x) ((lbtokg(x)+5)/100) /*!< Zangband基準のポンド→キログラム変換定義(整数部) */
41 #define lbtokg2(x) ( ( (lbtokg(x)+5)%100)/10)  /*!< Zangband基準のポンド→キログラム変換定義(少数部) */
42 #elif defined(JP)
43 #define lbtokg(x) ((int)((x)*5)) /*!< 変愚蛮怒基準のポンド→キログラム変換定義(全体) */
44 #define lbtokg1(x) (lbtokg(x)/100) /*!< 変愚蛮怒基準のポンド→キログラム変換定義(整数部) */
45 #define lbtokg2(x) ((lbtokg(x)%100)/10)  /*!< 変愚蛮怒基準のポンド→キログラム変換定義(少数部) */
46 #endif
47
48 /*
49  * Force a character to lowercase/uppercase
50  */
51 #define FORCELOWER(A)  ((isupper((A))) ? tolower((A)) : (A))
52 #define FORCEUPPER(A)  ((islower((A))) ? toupper((A)) : (A))
53
54
55 /*
56  * Non-typed minimum value macro
57  */
58 #undef MIN
59 #define MIN(a,b)        (((a) > (b)) ? (b)  : (a))
60
61 /*
62  * Non-typed maximum value macro
63  */
64 #undef MAX
65 #define MAX(a,b)        (((a) < (b)) ? (b)  : (a))
66
67 /*
68  * Non-typed absolute value macro
69  */
70 #undef ABS
71 #define ABS(a)          (((a) < 0)   ? (-(a)) : (a))
72
73 /*
74  * Non-typed sign extractor macro
75  */
76 #undef SGN
77 #define SGN(a)          (((a) < 0)   ? (-1) : ((a) != 0))
78
79 /*
80  * Refer to the member at offset of structure
81  */
82 #define atoffset(TYPE, STRUCT_PTR, OFFSET) (*(TYPE*)(((char*)STRUCT_PTR) + (OFFSET)))
83
84 #endif
85