TrinityCore
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#else // TRINITY_PLATFORM != TRINITY_PLATFORM_WINDOWS
63# define TRINITY_PATH_MAX PATH_MAX
64#endif // TRINITY_PLATFORM
65
66#if !defined(COREDEBUG)
67# define TRINITY_INLINE inline
68#else //COREDEBUG
69# if !defined(TRINITY_DEBUG)
70# define TRINITY_DEBUG
71# endif //TRINITY_DEBUG
72# define TRINITY_INLINE
73#endif
74
75#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
76# define ATTR_PRINTF(F, V) __attribute__ ((__format__ (__printf__, F, V)))
77#else //TRINITY_COMPILER != TRINITY_COMPILER_GNU
78# define ATTR_PRINTF(F, V)
79#endif //TRINITY_COMPILER == TRINITY_COMPILER_GNU
80
81#ifdef TRINITY_API_USE_DYNAMIC_LINKING
82# if TRINITY_COMPILER == TRINITY_COMPILER_MICROSOFT
83# define TC_API_EXPORT __declspec(dllexport)
84# define TC_API_IMPORT __declspec(dllimport)
85# elif TRINITY_COMPILER == TRINITY_COMPILER_GNU
86# define TC_API_EXPORT __attribute__((visibility("default")))
87# define TC_API_IMPORT
88# else
89# error compiler not supported!
90# endif
91#else
92# define TC_API_EXPORT
93# define TC_API_IMPORT
94#endif
95
96#ifdef TRINITY_API_EXPORT_COMMON
97# define TC_COMMON_API TC_API_EXPORT
98#else
99# define TC_COMMON_API TC_API_IMPORT
100#endif
101
102#ifdef TRINITY_API_EXPORT_PROTO
103# define TC_PROTO_API TC_API_EXPORT
104#else
105# define TC_PROTO_API TC_API_IMPORT
106#endif
107
108#ifdef TRINITY_API_EXPORT_DATABASE
109# define TC_DATABASE_API TC_API_EXPORT
110#else
111# define TC_DATABASE_API TC_API_IMPORT
112#endif
113
114#ifdef TRINITY_API_EXPORT_SHARED
115# define TC_SHARED_API TC_API_EXPORT
116#else
117# define TC_SHARED_API TC_API_IMPORT
118#endif
119
120#ifdef TRINITY_API_EXPORT_GAME
121# define TC_GAME_API TC_API_EXPORT
122#else
123# define TC_GAME_API TC_API_IMPORT
124#endif
125
126#define UI64FMTD "%" PRIu64
127#define UI64LIT(N) UINT64_C(N)
128
129#define SI64FMTD "%" PRId64
130#define SI64LIT(N) INT64_C(N)
131
132#define SZFMTD "%" PRIuPTR
133
134#define STRING_VIEW_FMT "%.*s"
135#define STRING_VIEW_FMT_ARG(str) static_cast<int>((str).length()), (str).data()
136
137typedef int64_t int64;
138typedef int32_t int32;
139typedef int16_t int16;
140typedef int8_t int8;
141typedef uint64_t uint64;
142typedef uint32_t uint32;
143typedef uint16_t uint16;
144typedef uint8_t uint8;
145
147{
148 FT_STRING = 's', // LocalizedString*
150 FT_FLOAT = 'f', // float
151 FT_INT = 'i', // uint32
152 FT_BYTE = 'b', // uint8
153 FT_SHORT = 'h', // uint16
154 FT_LONG = 'l' // uint64
156
157#endif //TRINITY_DEFINE_H
uint8_t uint8
Definition: Define.h:144
int64_t int64
Definition: Define.h:137
int16_t int16
Definition: Define.h:139
int8_t int8
Definition: Define.h:140
int32_t int32
Definition: Define.h:138
uint64_t uint64
Definition: Define.h:141
uint16_t uint16
Definition: Define.h:143
DBCFormer
Definition: Define.h:147
@ FT_FLOAT
Definition: Define.h:150
@ FT_SHORT
Definition: Define.h:153
@ FT_STRING
Definition: Define.h:148
@ FT_INT
Definition: Define.h:151
@ FT_STRING_NOT_LOCALIZED
Definition: Define.h:149
@ FT_BYTE
Definition: Define.h:152
@ FT_LONG
Definition: Define.h:154
uint32_t uint32
Definition: Define.h:142