Core/Misc: Prefix all preprocessor defines from CompilerDefs with TRINITY_ to avoid conflicts (PLATFORM_WINDOWS is used/defined by CascLib)

This commit is contained in:
Shauren
2017-03-04 18:44:13 +01:00
parent 61829e269e
commit b8db320bf1
23 changed files with 67 additions and 84 deletions

View File

@@ -53,14 +53,14 @@
#include "Threading/LockedQueue.h"
#if PLATFORM == PLATFORM_WINDOWS
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
# include <ws2tcpip.h>
# if defined(__INTEL_COMPILER)
# if TRINITY_COMPILER == TRINITY_COMPILER_INTEL
# if !defined(BOOST_ASIO_HAS_MOVE)
# define BOOST_ASIO_HAS_MOVE
# endif // !defined(BOOST_ASIO_HAS_MOVE)
# endif // if defined(__INTEL_COMPILER)
# endif // if TRINITY_COMPILER == TRINITY_COMPILER_INTEL
#else
# include <sys/types.h>
@@ -71,7 +71,7 @@
# include <netdb.h>
#endif
#if COMPILER == COMPILER_MICROSOFT
#if TRINITY_COMPILER == TRINITY_COMPILER_MICROSOFT
#include <float.h>

View File

@@ -19,37 +19,37 @@
#ifndef TRINITY_COMPILERDEFS_H
#define TRINITY_COMPILERDEFS_H
#define PLATFORM_WINDOWS 0
#define PLATFORM_UNIX 1
#define PLATFORM_APPLE 2
#define PLATFORM_INTEL 3
#define TRINITY_PLATFORM_WINDOWS 0
#define TRINITY_PLATFORM_UNIX 1
#define TRINITY_PLATFORM_APPLE 2
#define TRINITY_PLATFORM_INTEL 3
// must be first (win 64 also define _WIN32)
#if defined( _WIN64 )
# define PLATFORM PLATFORM_WINDOWS
# define TRINITY_PLATFORM TRINITY_PLATFORM_WINDOWS
#elif defined( __WIN32__ ) || defined( WIN32 ) || defined( _WIN32 )
# define PLATFORM PLATFORM_WINDOWS
# define TRINITY_PLATFORM TRINITY_PLATFORM_WINDOWS
#elif defined( __APPLE_CC__ )
# define PLATFORM PLATFORM_APPLE
# define TRINITY_PLATFORM TRINITY_PLATFORM_APPLE
#elif defined( __INTEL_COMPILER )
# define PLATFORM PLATFORM_INTEL
# define TRINITY_PLATFORM TRINITY_PLATFORM_INTEL
#else
# define PLATFORM PLATFORM_UNIX
# define TRINITY_PLATFORM TRINITY_PLATFORM_UNIX
#endif
#define COMPILER_MICROSOFT 0
#define COMPILER_GNU 1
#define COMPILER_BORLAND 2
#define COMPILER_INTEL 3
#define TRINITY_COMPILER_MICROSOFT 0
#define TRINITY_COMPILER_GNU 1
#define TRINITY_COMPILER_BORLAND 2
#define TRINITY_COMPILER_INTEL 3
#ifdef _MSC_VER
# define COMPILER COMPILER_MICROSOFT
# define TRINITY_COMPILER TRINITY_COMPILER_MICROSOFT
#elif defined( __BORLANDC__ )
# define COMPILER COMPILER_BORLAND
# define TRINITY_COMPILER TRINITY_COMPILER_BORLAND
#elif defined( __INTEL_COMPILER )
# define COMPILER COMPILER_INTEL
# define TRINITY_COMPILER TRINITY_COMPILER_INTEL
#elif defined( __GNUC__ )
# define COMPILER COMPILER_GNU
# define TRINITY_COMPILER TRINITY_COMPILER_GNU
# define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#else
# error "FATAL ERROR: Unknown compiler."

View File

@@ -38,7 +38,7 @@ namespace Trinity
} // namespace Trinity
#if COMPILER == COMPILER_MICROSOFT
#if TRINITY_COMPILER == TRINITY_COMPILER_MICROSOFT
#define ASSERT_BEGIN __pragma(warning(push)) __pragma(warning(disable: 4127))
#define ASSERT_END __pragma(warning(pop))
#else

View File

@@ -5,7 +5,7 @@
//==========================================
#include "CompilerDefs.h"
#if PLATFORM == PLATFORM_WINDOWS && !defined(__MINGW32__)
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS && !defined(__MINGW32__)
#define WIN32_LEAN_AND_MEAN
#pragma warning(disable:4996)
#pragma warning(disable:4312)

View File

@@ -1,7 +1,7 @@
#ifndef _WHEATYEXCEPTIONREPORT_
#define _WHEATYEXCEPTIONREPORT_
#if PLATFORM == PLATFORM_WINDOWS && !defined(__MINGW32__)
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS && !defined(__MINGW32__)
#include <winnt.h>
#include <winternl.h>

View File

@@ -21,7 +21,7 @@
#include "CompilerDefs.h"
#if COMPILER == COMPILER_GNU
#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
# if !defined(__STDC_FORMAT_MACROS)
# define __STDC_FORMAT_MACROS
# endif
@@ -55,7 +55,7 @@
# endif
#endif
#if PLATFORM == PLATFORM_WINDOWS
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
# define TRINITY_PATH_MAX MAX_PATH
# define _USE_MATH_DEFINES
# ifndef DECLSPEC_NORETURN
@@ -64,11 +64,11 @@
# ifndef DECLSPEC_DEPRECATED
# define DECLSPEC_DEPRECATED __declspec(deprecated)
# endif //DECLSPEC_DEPRECATED
#else //PLATFORM != PLATFORM_WINDOWS
#else // TRINITY_PLATFORM != TRINITY_PLATFORM_WINDOWS
# define TRINITY_PATH_MAX PATH_MAX
# define DECLSPEC_NORETURN
# define DECLSPEC_DEPRECATED
#endif //PLATFORM
#endif // TRINITY_PLATFORM
#if !defined(COREDEBUG)
# define TRINITY_INLINE inline
@@ -79,21 +79,21 @@
# define TRINITY_INLINE
#endif //!COREDEBUG
#if COMPILER == COMPILER_GNU
#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
# define ATTR_NORETURN __attribute__((__noreturn__))
# define ATTR_PRINTF(F, V) __attribute__ ((__format__ (__printf__, F, V)))
# define ATTR_DEPRECATED __attribute__((__deprecated__))
#else //COMPILER != COMPILER_GNU
#else //TRINITY_COMPILER != TRINITY_COMPILER_GNU
# define ATTR_NORETURN
# define ATTR_PRINTF(F, V)
# define ATTR_DEPRECATED
#endif //COMPILER == COMPILER_GNU
#endif //TRINITY_COMPILER == TRINITY_COMPILER_GNU
#ifdef TRINITY_API_USE_DYNAMIC_LINKING
# if COMPILER == COMPILER_MICROSOFT
# if TRINITY_COMPILER == TRINITY_COMPILER_MICROSOFT
# define TC_API_EXPORT __declspec(dllexport)
# define TC_API_IMPORT __declspec(dllimport)
# elif COMPILER == COMPILER_GNU
# elif TRINITY_COMPILER == TRINITY_COMPILER_GNU
# define TC_API_EXPORT __attribute__((visibility("default")))
# define TC_API_IMPORT
# else

View File

@@ -46,17 +46,17 @@ char const* GitRevision::GetHotfixesDatabase()
return _HOTFIXES_DATABASE;
}
#if PLATFORM == PLATFORM_WINDOWS
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
# ifdef _WIN64
# define TRINITY_PLATFORM_STR "Win64"
# else
# define TRINITY_PLATFORM_STR "Win32"
# endif
#elif PLATFORM == PLATFORM_APPLE
#elif TRINITY_PLATFORM == TRINITY_PLATFORM_APPLE
# define TRINITY_PLATFORM_STR "MacOSX"
#elif PLATFORM == PLATFORM_INTEL
#elif TRINITY_PLATFORM == TRINITY_PLATFORM_INTEL
# define TRINITY_PLATFORM_STR "Intel"
#else // PLATFORM_UNIX
#else // TRINITY_PLATFORM_UNIX
# define TRINITY_PLATFORM_STR "Unix"
#endif

View File

@@ -21,7 +21,7 @@
#include "Config.h"
#include "Util.h"
#if PLATFORM == PLATFORM_WINDOWS
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
#include <Windows.h>
#endif
@@ -66,7 +66,7 @@ void AppenderConsole::InitColors(std::string const& str)
void AppenderConsole::SetColor(bool stdout_stream, ColorTypes color)
{
#if PLATFORM == PLATFORM_WINDOWS
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
static WORD WinColorFG[MaxColors] =
{
0, // BLACK
@@ -153,7 +153,7 @@ void AppenderConsole::SetColor(bool stdout_stream, ColorTypes color)
void AppenderConsole::ResetColor(bool stdout_stream)
{
#if PLATFORM == PLATFORM_WINDOWS
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
HANDLE hConsole = GetStdHandle(stdout_stream ? STD_OUTPUT_HANDLE : STD_ERROR_HANDLE);
SetConsoleTextAttribute(hConsole, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED);
#else

View File

@@ -20,7 +20,7 @@
#include "StringFormat.h"
#include "Log.h"
#if PLATFORM == PLATFORM_WINDOWS
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
# include <Windows.h>
#endif

View File

@@ -166,7 +166,7 @@ inline bool Log::ShouldLog(std::string const& type, LogLevel level) const
} \
}
#if PLATFORM != PLATFORM_WINDOWS
#if TRINITY_PLATFORM != TRINITY_PLATFORM_WINDOWS
void check_args(const char*, ...) ATTR_PRINTF(1, 2);
void check_args(std::string const&, ...);

View File

@@ -116,7 +116,7 @@ public:
#define sMetric Metric::instance()
#if PLATFORM != PLATFORM_WINDOWS
#if TRINITY_PLATFORM != TRINITY_PLATFORM_WINDOWS
#define TC_METRIC_EVENT(category, title, description) \
do { \
if (sMetric->IsEnabled()) \

View File

@@ -28,11 +28,6 @@
void SetProcessPriority(const std::string& logChannel)
{
// Suppresses Mac OS X Warning since logChannel isn't used.
#if PLATFORM_APPLE
(void)logChannel;
#endif
#if defined(_WIN32) || defined(__linux__)
///- Handle affinity for multiple processors and process priority
@@ -99,6 +94,9 @@ void SetProcessPriority(const std::string& logChannel)
}
#endif
#else
// Suppresses unused argument warning for all other platforms
(void)logChannel;
#endif
}

View File

@@ -24,7 +24,7 @@
#include <stdarg.h>
#include <boost/algorithm/string/case_conv.hpp>
#if COMPILER == COMPILER_GNU
#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@@ -421,7 +421,7 @@ std::wstring GetMainPartOfName(std::wstring const& wname, uint32 declension)
bool utf8ToConsole(const std::string& utf8str, std::string& conStr)
{
#if PLATFORM == PLATFORM_WINDOWS
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
std::wstring wstr;
if (!Utf8toWStr(utf8str, wstr))
return false;
@@ -438,7 +438,7 @@ bool utf8ToConsole(const std::string& utf8str, std::string& conStr)
bool consoleToUtf8(const std::string& conStr, std::string& utf8str)
{
#if PLATFORM == PLATFORM_WINDOWS
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
std::wstring wstr;
wstr.resize(conStr.size());
OemToCharBuffW(&conStr[0], &wstr[0], uint32(conStr.size()));
@@ -477,7 +477,7 @@ void utf8printf(FILE* out, const char *str, ...)
void vutf8printf(FILE* out, const char *str, va_list* ap)
{
#if PLATFORM == PLATFORM_WINDOWS
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
char temp_buf[32 * 1024];
wchar_t wtemp_buf[32 * 1024];

View File

@@ -45,7 +45,7 @@ namespace fs = boost::filesystem;
# define _TRINITY_BNET_CONFIG "bnetserver.conf"
#endif
#if PLATFORM == PLATFORM_WINDOWS
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
#include "ServiceWin32.h"
char serviceName[] = "bnetserver";
char serviceLongName[] = "TrinityCore bnet service";
@@ -88,7 +88,7 @@ int main(int argc, char** argv)
GOOGLE_PROTOBUF_VERIFY_VERSION;
#if PLATFORM == PLATFORM_WINDOWS
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
if (configService.compare("install") == 0)
return WinServiceInstall() ? 0 : 1;
else if (configService.compare("uninstall") == 0)
@@ -179,7 +179,7 @@ int main(int argc, char** argv)
// Set signal handlers
boost::asio::signal_set signals(*_ioService, SIGINT, SIGTERM);
#if PLATFORM == PLATFORM_WINDOWS
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
signals.add(SIGBREAK);
#endif
signals.async_wait(SignalHandler);
@@ -198,7 +198,7 @@ int main(int argc, char** argv)
_banExpiryCheckTimer->expires_from_now(boost::posix_time::seconds(_banExpiryCheckInterval));
_banExpiryCheckTimer->async_wait(BanExpiryHandler);
#if PLATFORM == PLATFORM_WINDOWS
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
if (m_ServiceStatus != -1)
{
_serviceStatusWatchTimer = new boost::asio::deadline_timer(*_ioService);
@@ -289,7 +289,7 @@ void BanExpiryHandler(boost::system::error_code const& error)
}
}
#if PLATFORM == PLATFORM_WINDOWS
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
void ServiceStatusWatcher(boost::system::error_code const& error)
{
if (!error)
@@ -319,7 +319,7 @@ variables_map GetConsoleArguments(int argc, char** argv, fs::path& configFile, s
("config,c", value<fs::path>(&configFile)->default_value(fs::absolute(_TRINITY_BNET_CONFIG)),
"use <arg> as configuration file")
;
#if PLATFORM == PLATFORM_WINDOWS
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
options_description win("Windows platform specific options");
win.add_options()
("service,s", value<std::string>(&configService)->default_value(""), "Windows service options: [install | uninstall]")

View File

@@ -1288,7 +1288,7 @@ void World::LoadConfigSettings(bool reload)
if (dataPath.empty() || (dataPath.at(dataPath.length()-1) != '/' && dataPath.at(dataPath.length()-1) != '\\'))
dataPath.push_back('/');
#if PLATFORM == PLATFORM_UNIX || PLATFORM == PLATFORM_APPLE
#if TRINITY_PLATFORM == TRINITY_PLATFORM_UNIX || TRINITY_PLATFORM == TRINITY_PLATFORM_APPLE
if (dataPath[0] == '~')
{
const char* home = getenv("HOME");

View File

@@ -35,7 +35,7 @@
#include "Player.h"
#include "Util.h"
#if PLATFORM != PLATFORM_WINDOWS
#if TRINITY_PLATFORM != TRINITY_PLATFORM_WINDOWS
#include <readline/readline.h>
#include <readline/history.h>
@@ -91,7 +91,7 @@ int cli_hook_func()
void utf8print(void* /*arg*/, const char* str)
{
#if PLATFORM == PLATFORM_WINDOWS
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
wchar_t wtemp_buf[6000];
size_t wtemp_len = 6000-1;
if (!Utf8toWStr(str, strlen(str), wtemp_buf, wtemp_len))
@@ -134,7 +134,7 @@ void CliThread()
{
///- Display the list of available CLI functions then beep
//TC_LOG_INFO("server.worldserver", "");
#if PLATFORM != PLATFORM_WINDOWS
#if TRINITY_PLATFORM != TRINITY_PLATFORM_WINDOWS
rl_attempted_completion_function = cli_completion;
rl_event_hook = cli_hook_func;
#endif
@@ -153,7 +153,7 @@ void CliThread()
char *command_str ; // = fgets(commandbuf, sizeof(commandbuf), stdin);
#if PLATFORM == PLATFORM_WINDOWS
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
char commandbuf[256];
command_str = fgets(commandbuf, sizeof(commandbuf), stdin);
#else
@@ -172,7 +172,7 @@ void CliThread()
if (!*command_str)
{
#if PLATFORM == PLATFORM_WINDOWS
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
printf("TC>");
#else
free(command_str);
@@ -183,7 +183,7 @@ void CliThread()
std::string command;
if (!consoleToUtf8(command_str, command)) // convert from console encoding to utf8
{
#if PLATFORM == PLATFORM_WINDOWS
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
printf("TC>");
#else
free(command_str);
@@ -193,7 +193,7 @@ void CliThread()
fflush(stdout);
sWorld->QueueCliCommand(new CliCommandHolder(NULL, command.c_str(), &utf8print, &commandFinished));
#if PLATFORM != PLATFORM_WINDOWS
#if TRINITY_PLATFORM != TRINITY_PLATFORM_WINDOWS
add_history(command.c_str());
free(command_str);
#endif

View File

@@ -168,7 +168,7 @@ extern int main(int argc, char** argv)
// Set signal handlers (this must be done before starting io_service threads, because otherwise they would unblock and exit)
boost::asio::signal_set signals(_ioService, SIGINT, SIGTERM);
#if PLATFORM == PLATFORM_WINDOWS
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
signals.add(SIGBREAK);
#endif
signals.async_wait(SignalHandler);

View File

@@ -31,9 +31,9 @@
#include <boost/algorithm/string/replace.hpp>
#include <boost/program_options.hpp>
#if PLATFORM == PLATFORM_WINDOWS
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
#include <Shlobj.h>
#elif PLATFORM == PLATFORM_UNIX
#elif TRINITY_PLATFORM == TRINITY_PLATFORM_UNIX
#include <pwd.h>
#endif

View File

@@ -19,9 +19,6 @@
#define MapExtractor_DB2_h__
#include "DB2Meta.h"
#ifdef PLATFORM_WINDOWS
#undef PLATFORM_WINDOWS
#endif
#include "CascHandles.h"
#include "CascLib.h"
#include "Utilities/ByteConverter.h"

View File

@@ -29,9 +29,6 @@
#include <boost/filesystem/operations.hpp>
#include "Common.h"
#ifdef PLATFORM_WINDOWS
#undef PLATFORM_WINDOWS
#endif
#include "DBFilesClientList.h"
#include "CascLib.h"
#include "CascHandles.h"

View File

@@ -20,9 +20,6 @@
#define LOAD_LIB_H
#include "Define.h"
#ifdef PLATFORM_WINDOWS
#undef PLATFORM_WINDOWS
#endif
#include "CascHandles.h"
#include "CascLib.h"
#include <map>

View File

@@ -19,9 +19,6 @@
#define MapExtractor_DB2_h__
#include "DB2Meta.h"
#ifdef PLATFORM_WINDOWS
#undef PLATFORM_WINDOWS
#endif
#include "CascHandles.h"
#include "CascLib.h"
#include "Utilities/ByteConverter.h"

View File

@@ -38,9 +38,6 @@
#include <fstream>
#include "Common.h"
#ifdef PLATFORM_WINDOWS
#undef PLATFORM_WINDOWS
#endif
//From Extractor
#include "adtfile.h"
#include "wdtfile.h"