TrinityCore
Loading...
Searching...
No Matches
Define.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef TRINITY_DEFINE_H
19#define TRINITY_DEFINE_H
20
21#include "CompilerDefs.h"
22
23#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
24# if !defined(__STDC_FORMAT_MACROS)
25# define __STDC_FORMAT_MACROS
26# endif
27# if !defined(__STDC_CONSTANT_MACROS)
28# define __STDC_CONSTANT_MACROS
29# endif
30# if !defined(_GLIBCXX_USE_NANOSLEEP)
31# define _GLIBCXX_USE_NANOSLEEP
32# endif
33# if defined(HELGRIND)
34# include <valgrind/helgrind.h>
35# undef _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE
36# undef _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER
37# define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A) ANNOTATE_HAPPENS_BEFORE(A)
38# define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A) ANNOTATE_HAPPENS_AFTER(A)
39# endif
40# if defined(VALGRIND)
41# include <valgrind/memcheck.h>
42# endif
43#endif
44
45#include <cstddef>
46#include <cinttypes>
47#include <climits>
48
49#define TRINITY_LITTLEENDIAN 0
50#define TRINITY_BIGENDIAN 1
51
52#if !defined(TRINITY_ENDIAN)
53# if defined (BOOST_BIG_ENDIAN)
54# define TRINITY_ENDIAN TRINITY_BIGENDIAN
55# else
56# define TRINITY_ENDIAN TRINITY_LITTLEENDIAN
57# endif
58#endif
59
60#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
61# define TRINITY_PATH_MAX 260
62# define _USE_MATH_DEFINES
63#else // TRINITY_PLATFORM != TRINITY_PLATFORM_WINDOWS
64# define TRINITY_PATH_MAX PATH_MAX
65#endif // TRINITY_PLATFORM
66
67#if !defined(COREDEBUG)
68# define TRINITY_INLINE inline
69#else //COREDEBUG
70# if !defined(TRINITY_DEBUG)
71# define TRINITY_DEBUG
72# endif //TRINITY_DEBUG
73# define TRINITY_INLINE
74#endif
75
76#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
77# define ATTR_PRINTF(F, V) __attribute__ ((__format__ (__printf__, F, V)))
78#else //TRINITY_COMPILER != TRINITY_COMPILER_GNU
79# define ATTR_PRINTF(F, V)
80#endif //TRINITY_COMPILER == TRINITY_COMPILER_GNU
81
82#ifdef TRINITY_API_USE_DYNAMIC_LINKING
83# if TRINITY_COMPILER == TRINITY_COMPILER_MICROSOFT
84# define TC_API_EXPORT __declspec(dllexport)
85# define TC_API_IMPORT __declspec(dllimport)
86# elif TRINITY_COMPILER == TRINITY_COMPILER_GNU
87# define TC_API_EXPORT __attribute__((visibility("default")))
88# define TC_API_IMPORT
89# else
90# error compiler not supported!
91# endif
92#else
93# define TC_API_EXPORT
94# define TC_API_IMPORT
95#endif
96
97#ifdef TRINITY_API_EXPORT_COMMON
98# define TC_COMMON_API TC_API_EXPORT
99#else
100# define TC_COMMON_API TC_API_IMPORT
101#endif
102
103#ifdef TRINITY_API_EXPORT_PROTO
104# define TC_PROTO_API TC_API_EXPORT
105#else
106# define TC_PROTO_API TC_API_IMPORT
107#endif
108
109#ifdef TRINITY_API_EXPORT_DATABASE
110# define TC_DATABASE_API TC_API_EXPORT
111#else
112# define TC_DATABASE_API TC_API_IMPORT
113#endif
114
115#ifdef TRINITY_API_EXPORT_SHARED
116# define TC_SHARED_API TC_API_EXPORT
117#else
118# define TC_SHARED_API TC_API_IMPORT
119#endif
120
121#ifdef TRINITY_API_EXPORT_GAME
122# define TC_GAME_API TC_API_EXPORT
123#else
124# define TC_GAME_API TC_API_IMPORT
125#endif
126
127#define UI64FMTD "%" PRIu64
128#define UI64LIT(N) UINT64_C(N)
129
130#define SI64FMTD "%" PRId64
131#define SI64LIT(N) INT64_C(N)
132
133#define SZFMTD "%" PRIuPTR
134
135#define STRING_VIEW_FMT "%.*s"
136#define STRING_VIEW_FMT_ARG(str) static_cast<int>((str).length()), (str).data()
137
138typedef int64_t int64;
139typedef int32_t int32;
140typedef int16_t int16;
141typedef int8_t int8;
142typedef uint64_t uint64;
143typedef uint32_t uint32;
144typedef uint16_t uint16;
145typedef uint8_t uint8;
146
148{
149 FT_STRING = 's', // LocalizedString*
151 FT_FLOAT = 'f', // float
152 FT_INT = 'i', // uint32
153 FT_BYTE = 'b', // uint8
154 FT_SHORT = 'h', // uint16
155 FT_LONG = 'l' // uint64
157
158#endif //TRINITY_DEFINE_H
uint8_t uint8
Definition: Define.h:145
int64_t int64
Definition: Define.h:138
int16_t int16
Definition: Define.h:140
int8_t int8
Definition: Define.h:141
int32_t int32
Definition: Define.h:139
uint64_t uint64
Definition: Define.h:142
uint16_t uint16
Definition: Define.h:144
DBCFormer
Definition: Define.h:148
@ FT_FLOAT
Definition: Define.h:151
@ FT_SHORT
Definition: Define.h:154
@ FT_STRING
Definition: Define.h:149
@ FT_INT
Definition: Define.h:152
@ FT_STRING_NOT_LOCALIZED
Definition: Define.h:150
@ FT_BYTE
Definition: Define.h:153
@ FT_LONG
Definition: Define.h:155
uint32_t uint32
Definition: Define.h:143