OSDN Git Service

[Refactor] #38862 Moved object*.c/h to object/
[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  * The constants "TRUE" and "FALSE"
14  */
15
16 #undef TRUE
17 #define TRUE    1 /*!< コンパイル環境に定義がない場合のTRUE定義 */
18
19 #undef FALSE
20 #define FALSE   0 /*!< コンパイル環境に定義がない場合のFALSE定義 */
21
22 /**** Simple "Macros" ****/
23 #ifdef JP
24 #define lbtokg(x) ((int)((x)*5)) /*!< 変愚蛮怒基準のポンド→キログラム変換定義(全体) */
25 #define lbtokg1(x) (lbtokg(x)/100) /*!< 変愚蛮怒基準のポンド→キログラム変換定義(整数部) */
26 #define lbtokg2(x) ((lbtokg(x)%100)/10)  /*!< 変愚蛮怒基準のポンド→キログラム変換定義(少数部) */
27 #endif
28
29 /*
30  * Force a character to lowercase/uppercase
31  */
32 #define FORCELOWER(A)  ((isupper((A))) ? tolower((A)) : (A))
33 #define FORCEUPPER(A)  ((islower((A))) ? toupper((A)) : (A))
34
35 /*
36  * Non-typed minimum value macro
37  */
38 #undef MIN
39 #define MIN(a,b)        (((a) > (b)) ? (b)  : (a))
40
41 /*
42  * Non-typed maximum value macro
43  */
44 #undef MAX
45 #define MAX(a,b)        (((a) < (b)) ? (b)  : (a))
46
47 /*
48  * Non-typed absolute value macro
49  */
50 #undef ABS
51 #define ABS(a)          (((a) < 0)   ? (-(a)) : (a))
52
53 /*
54  * Non-typed sign extractor macro
55  */
56 #undef SGN
57 #define SGN(a)          (((a) < 0)   ? (-1) : ((a) != 0))
58
59 /*
60  * Refer to the member at offset of structure
61  */
62 #define atoffset(TYPE, STRUCT_PTR, OFFSET) (*(TYPE*)(((char*)STRUCT_PTR) + (OFFSET)))
63
64 #endif