TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Define.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
3  * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the
7  * Free Software Foundation; either version 2 of the License, or (at your
8  * option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef TRINITY_DEFINE_H
20 #define TRINITY_DEFINE_H
21 
22 #include "CompilerDefs.h"
23 
24 #if COMPILER == COMPILER_GNU
25 # if !defined(__STDC_FORMAT_MACROS)
26 # define __STDC_FORMAT_MACROS
27 # endif
28 # if !defined(__STDC_CONSTANT_MACROS)
29 # define __STDC_CONSTANT_MACROS
30 # endif
31 # if !defined(_GLIBCXX_USE_NANOSLEEP)
32 # define _GLIBCXX_USE_NANOSLEEP
33 # endif
34 # if defined(HELGRIND)
35 # include <valgrind/helgrind.h>
36 # undef _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE
37 # undef _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER
38 # define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A) ANNOTATE_HAPPENS_BEFORE(A)
39 # define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A) ANNOTATE_HAPPENS_AFTER(A)
40 # endif
41 #endif
42 
43 #include <cstddef>
44 #include <cinttypes>
45 #include <climits>
46 
47 #define TRINITY_LITTLEENDIAN 0
48 #define TRINITY_BIGENDIAN 1
49 
50 #if !defined(TRINITY_ENDIAN)
51 # if defined (BOOST_BIG_ENDIAN)
52 # define TRINITY_ENDIAN TRINITY_BIGENDIAN
53 # else
54 # define TRINITY_ENDIAN TRINITY_LITTLEENDIAN
55 # endif
56 #endif
57 
58 #if PLATFORM == PLATFORM_WINDOWS
59 # define TRINITY_PATH_MAX MAX_PATH
60 # define _USE_MATH_DEFINES
61 # ifndef DECLSPEC_NORETURN
62 # define DECLSPEC_NORETURN __declspec(noreturn)
63 # endif //DECLSPEC_NORETURN
64 # ifndef DECLSPEC_DEPRECATED
65 # define DECLSPEC_DEPRECATED __declspec(deprecated)
66 # endif //DECLSPEC_DEPRECATED
67 #else //PLATFORM != PLATFORM_WINDOWS
68 # define TRINITY_PATH_MAX PATH_MAX
69 # define DECLSPEC_NORETURN
70 # define DECLSPEC_DEPRECATED
71 #endif //PLATFORM
72 
73 #if !defined(COREDEBUG)
74 # define TRINITY_INLINE inline
75 #else //COREDEBUG
76 # if !defined(TRINITY_DEBUG)
77 # define TRINITY_DEBUG
78 # endif //TRINITY_DEBUG
79 # define TRINITY_INLINE
80 #endif
81 
82 #if COMPILER == COMPILER_GNU
83 # define ATTR_NORETURN __attribute__((__noreturn__))
84 # define ATTR_PRINTF(F, V) __attribute__ ((__format__ (__printf__, F, V)))
85 # define ATTR_DEPRECATED __attribute__((__deprecated__))
86 # define TRINITY_CONSTEXPR constexpr
87 #else //COMPILER != COMPILER_GNU
88 # define ATTR_NORETURN
89 # define ATTR_PRINTF(F, V)
90 # define ATTR_DEPRECATED
91 #if _MSC_VER >= 1900
92 # define TRINITY_CONSTEXPR constexpr
93 #else
94 # define TRINITY_CONSTEXPR
95 #endif
96 #endif //COMPILER == COMPILER_GNU
97 
98 #ifdef TRINITY_API_USE_DYNAMIC_LINKING
99 # if COMPILER == COMPILER_MICROSOFT
100 # define TC_API_EXPORT __declspec(dllexport)
101 # define TC_API_IMPORT __declspec(dllimport)
102 # elif COMPILER == COMPILER_GNU
103 # define TC_API_EXPORT __attribute__((visibility("default")))
104 # define TC_API_IMPORT
105 # else
106 # error compiler not supported!
107 # endif
108 #else
109 # define TC_API_EXPORT
110 # define TC_API_IMPORT
111 #endif
112 
113 #ifdef TRINITY_API_EXPORT_COMMON
114 # define TC_COMMON_API TC_API_EXPORT
115 #else
116 # define TC_COMMON_API TC_API_IMPORT
117 #endif
118 
119 #ifdef TRINITY_API_EXPORT_DATABASE
120 # define TC_DATABASE_API TC_API_EXPORT
121 #else
122 # define TC_DATABASE_API TC_API_IMPORT
123 #endif
124 
125 #ifdef TRINITY_API_EXPORT_SHARED
126 # define TC_SHARED_API TC_API_EXPORT
127 #else
128 # define TC_SHARED_API TC_API_IMPORT
129 #endif
130 
131 #ifdef TRINITY_API_EXPORT_GAME
132 # define TC_GAME_API TC_API_EXPORT
133 #else
134 # define TC_GAME_API TC_API_IMPORT
135 #endif
136 
137 #define UI64FMTD "%" PRIu64
138 #define UI64LIT(N) UINT64_C(N)
139 
140 #define SI64FMTD "%" PRId64
141 #define SI64LIT(N) INT64_C(N)
142 
143 #define SZFMTD "%" PRIuPTR
144 
145 typedef int64_t int64;
146 typedef int32_t int32;
147 typedef int16_t int16;
148 typedef int8_t int8;
149 typedef uint64_t uint64;
150 typedef uint32_t uint32;
151 typedef uint16_t uint16;
152 typedef uint8_t uint8;
153 
155 {
156  FT_NA = 'x', //not used or unknown, 4 byte size
157  FT_NA_BYTE = 'X', //not used or unknown, byte
158  FT_STRING = 's', //char*
159  FT_STRING_NOT_LOCALIZED = 'S', //char* but without locale in DB2
160  FT_FLOAT = 'f', //float
161  FT_INT = 'i', //uint32
162  FT_BYTE = 'b', //uint8
163  FT_LONG = 'l', //uint64
164  FT_SORT = 'd', //sorted by this field, field is not included
165  FT_IND = 'n', //the same, but parsed to data
166  FT_SQL_PRESENT = 'p', //Used in sql format to mark column present in sql dbc
167  FT_SQL_ABSENT = 'a' //Used in sql format to mark column absent in sql dbc
168 };
169 
170 #endif //TRINITY_DEFINE_H
Definition: Define.h:163
int8_t int8
Definition: Define.h:148
Definition: Define.h:161
signed short int16_t
Definition: stdint.h:76
int64_t int64
Definition: Define.h:145
Definition: Define.h:160
signed __int64 int64_t
Definition: stdint.h:89
DBCFormer
Definition: Define.h:154
unsigned int uint32_t
Definition: stdint.h:80
Definition: Define.h:167
unsigned __int64 uint64_t
Definition: stdint.h:90
Definition: Define.h:165
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
uint64_t uint64
Definition: Define.h:149
uint16_t uint16
Definition: Define.h:151
Definition: Define.h:162
unsigned char uint8_t
Definition: stdint.h:78
signed char int8_t
Definition: stdint.h:75
Definition: Define.h:158
uint8_t uint8
Definition: Define.h:152
signed int int32_t
Definition: stdint.h:77
Definition: Define.h:164
int16_t int16
Definition: Define.h:147
Definition: Define.h:157
Definition: Define.h:159
Definition: Define.h:166
unsigned short uint16_t
Definition: stdint.h:79
Definition: Define.h:156