-
Notifications
You must be signed in to change notification settings - Fork 2
/
defs.h
77 lines (66 loc) · 2.52 KB
/
defs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//. defs.h - common, basic definitions
// Copyright (C) 1997,1998 hkuno
// mailto:[email protected]
#ifndef DEFS_H_
#define DEFS_H_
#include <stdexcept>
//------------------------------------------------------------------------
//. 環境スイッチ
//------------------------------------------------------------------------
#if (defined(__WIN32__) || defined(_WIN32)) && !defined(WIN32)
// WIN32環境のスイッチを共通化する
// BCBでは __WIN32__
// VC++では _WIN32
#define WIN32
#endif
//------------------------------------------------------------------------
//. 記憶クラス属性
//------------------------------------------------------------------------
#if defined(_MSC_VER) || defined(__BORLANDC__)
#define THREAD __declspec(thread)
#define EXPORT __declspec(export)
#define IMPORT __declspec(import)
#else
// DLLやスレッドをサポートしない環境では空マクロにしておく
#define THREAD
#define EXPORT
#define IMPORT
#endif
//------------------------------------------------------------------------
//. signed/unsigned type alias
//------------------------------------------------------------------------
typedef unsigned int uint;
typedef signed char schar;
typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned long ulong;
//------------------------------------------------------------------------
//. bit-sized int
//------------------------------------------------------------------------
// ※処理系やターゲット環境によっては修正が必要である
typedef signed char int8;
typedef short int16;
typedef long int32;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned long uint32;
//------------------------------------------------------------------------
//. 例外
//------------------------------------------------------------------------
class IOException : public std::runtime_error {
public: IOException(const char* msg) : std::runtime_error(msg) {}
};
class FileNotOpened : public IOException {
public: FileNotOpened(const char* msg) : IOException(msg) {}
};
class NullPointer : public std::logic_error {
public: NullPointer(const char* msg) : std::logic_error(msg) {}
};
#define NULLCHECK(p) { if (p == 0) throw NullPointer(""); }
//------------------------------------------------------------------------
//. macros
//------------------------------------------------------------------------
//. ELEMENTS_OF - 配列要素数の取得
#define ELEMENTS_OF(array) \
(sizeof(array) / sizeof(array[0]))
#endif // DEFS_H_