Core/Misc: Changed compiler detection to better support compilers that pretend to be something else, such as clang-cl is both msvc and clang at the same time
This commit is contained in:
@@ -30,19 +30,49 @@
|
||||
# define TRINITY_PLATFORM TRINITY_PLATFORM_UNIX
|
||||
#endif
|
||||
|
||||
#define TRINITY_COMPILER_MICROSOFT 0
|
||||
#define TRINITY_COMPILER_GNU 1
|
||||
#define TRINITY_COMPILER_INTEL 2
|
||||
#define TRINITY_COMPILER_MICROSOFT_FLAG(on) ((on) << 0)
|
||||
#define TRINITY_COMPILER_GCC_FLAG(on) ((on) << 1)
|
||||
#define TRINITY_COMPILER_CLANG_FLAG(on) ((on) << 2)
|
||||
#define TRINITY_COMPILER_INTEL_FLAG(on) ((on) << 3)
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define TRINITY_COMPILER TRINITY_COMPILER_MICROSOFT
|
||||
#elif defined( __INTEL_COMPILER )
|
||||
# define TRINITY_COMPILER TRINITY_COMPILER_INTEL
|
||||
#elif defined( __GNUC__ )
|
||||
# define TRINITY_COMPILER TRINITY_COMPILER_GNU
|
||||
# define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
|
||||
# define TRINITY_COMPILER_MICROSOFT_DETECTED 1
|
||||
#else
|
||||
# define TRINITY_COMPILER_MICROSOFT_DETECTED 0
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
# define TRINITY_COMPILER_GCC_DETECTED 1
|
||||
#else
|
||||
# define TRINITY_COMPILER_GCC_DETECTED 0
|
||||
#endif
|
||||
|
||||
#ifdef __clang__
|
||||
# define TRINITY_COMPILER_CLANG_DETECTED 1
|
||||
#else
|
||||
# define TRINITY_COMPILER_CLANG_DETECTED 0
|
||||
#endif
|
||||
|
||||
#ifdef __INTEL_COMPILER
|
||||
# define TRINITY_COMPILER_INTEL_DETECTED 1
|
||||
#else
|
||||
# define TRINITY_COMPILER_INTEL_DETECTED 0
|
||||
#endif
|
||||
|
||||
#define TRINITY_COMPILER \
|
||||
( TRINITY_COMPILER_MICROSOFT_FLAG(TRINITY_COMPILER_MICROSOFT_DETECTED) \
|
||||
| TRINITY_COMPILER_GCC_FLAG(TRINITY_COMPILER_GCC_DETECTED) \
|
||||
| TRINITY_COMPILER_CLANG_FLAG(TRINITY_COMPILER_CLANG_DETECTED) \
|
||||
| TRINITY_COMPILER_INTEL_FLAG(TRINITY_COMPILER_INTEL_DETECTED) )
|
||||
|
||||
#if TRINITY_COMPILER == 0
|
||||
# error "FATAL ERROR: Unknown compiler."
|
||||
#endif
|
||||
|
||||
#define TRINITY_COMPILER_IS(compiler) (((TRINITY_COMPILER) & (compiler)) != 0)
|
||||
#define TRINITY_COMPILER_IS_MICROSOFT TRINITY_COMPILER_IS(TRINITY_COMPILER_MICROSOFT_FLAG(1))
|
||||
#define TRINITY_COMPILER_IS_GCC TRINITY_COMPILER_IS(TRINITY_COMPILER_GCC_FLAG(1))
|
||||
#define TRINITY_COMPILER_IS_CLANG TRINITY_COMPILER_IS(TRINITY_COMPILER_CLANG_FLAG(1))
|
||||
#define TRINITY_COMPILER_IS_INTEL TRINITY_COMPILER_IS(TRINITY_COMPILER_INTEL_FLAG(1))
|
||||
|
||||
#endif
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
terminates the application.
|
||||
*/
|
||||
|
||||
#if TRINITY_COMPILER == TRINITY_COMPILER_MICROSOFT
|
||||
#if TRINITY_COMPILER_IS_MICROSOFT
|
||||
#define Unreachable() (__assume(false))
|
||||
#else
|
||||
#define Unreachable() (__builtin_unreachable())
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace Trinity
|
||||
}
|
||||
} // namespace Trinity
|
||||
|
||||
#if TRINITY_COMPILER == TRINITY_COMPILER_MICROSOFT
|
||||
#if TRINITY_COMPILER_IS_MICROSOFT
|
||||
#define ASSERT_BEGIN __pragma(warning(push)) __pragma(warning(disable: 4127))
|
||||
#define ASSERT_END __pragma(warning(pop))
|
||||
#else
|
||||
|
||||
+6
-6
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "CompilerDefs.h"
|
||||
|
||||
#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
|
||||
#if TRINITY_COMPILER_IS_GCC
|
||||
# if !defined(__STDC_FORMAT_MACROS)
|
||||
# define __STDC_FORMAT_MACROS
|
||||
# endif
|
||||
@@ -72,17 +72,17 @@
|
||||
# define TRINITY_INLINE
|
||||
#endif //!COREDEBUG
|
||||
|
||||
#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
|
||||
#if TRINITY_COMPILER_IS_GCC
|
||||
# define ATTR_PRINTF(F, V) __attribute__ ((__format__ (__printf__, F, V)))
|
||||
#else //TRINITY_COMPILER != TRINITY_COMPILER_GNU
|
||||
#else //TRINITY_COMPILER_IS_GCC
|
||||
# define ATTR_PRINTF(F, V)
|
||||
#endif //TRINITY_COMPILER == TRINITY_COMPILER_GNU
|
||||
#endif //TRINITY_COMPILER_IS_GCC
|
||||
|
||||
#ifdef TRINITY_API_USE_DYNAMIC_LINKING
|
||||
# if TRINITY_COMPILER == TRINITY_COMPILER_MICROSOFT
|
||||
# if TRINITY_COMPILER_IS_MICROSOFT
|
||||
# define TC_API_EXPORT __declspec(dllexport)
|
||||
# define TC_API_IMPORT __declspec(dllimport)
|
||||
# elif TRINITY_COMPILER == TRINITY_COMPILER_GNU
|
||||
# elif TRINITY_COMPILER_IS_GCC
|
||||
# define TC_API_EXPORT __attribute__((visibility("default")))
|
||||
# define TC_API_IMPORT
|
||||
# else
|
||||
|
||||
@@ -165,7 +165,7 @@ class TC_COMMON_API Log
|
||||
|
||||
#ifdef PERFORMANCE_PROFILING
|
||||
#define TC_LOG_MESSAGE_BODY(filterType__, level__, message__, ...) ((void)0)
|
||||
#elif TRINITY_PLATFORM != TRINITY_PLATFORM_WINDOWS
|
||||
#elif !TRINITY_COMPILER_IS_MICROSOFT
|
||||
#define TC_LOG_MESSAGE_BODY(filterType__, level__, message__, ...) TC_LOG_MESSAGE_BODY_CORE(filterType__, level__, message__, ## __VA_ARGS__)
|
||||
#else
|
||||
#define TC_LOG_MESSAGE_BODY(filterType__, level__, message__, ...) \
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include <concepts>
|
||||
#include <memory>
|
||||
|
||||
#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
|
||||
#if TRINITY_COMPILER_IS_GCC
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wignored-attributes"
|
||||
#endif
|
||||
@@ -167,7 +167,7 @@ inline std::unique_ptr<T, Impl::stateless_unique_ptr_deleter<Ptr, Del>> make_uni
|
||||
}
|
||||
}
|
||||
|
||||
#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
|
||||
#if TRINITY_COMPILER_IS_GCC
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
{
|
||||
ASSERT(!my_child, "Process started already!");
|
||||
|
||||
#if TRINITY_COMPILER == TRINITY_COMPILER_MICROSOFT
|
||||
#if TRINITY_COMPILER_IS_MICROSOFT
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4297)
|
||||
/*
|
||||
@@ -89,7 +89,7 @@ public:
|
||||
#endif
|
||||
bp::ipstream outStream;
|
||||
bp::ipstream errStream;
|
||||
#if TRINITY_COMPILER == TRINITY_COMPILER_MICROSOFT
|
||||
#if TRINITY_COMPILER_IS_MICROSOFT
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@ namespace Trinity::Impl::StringConvertImpl
|
||||
}
|
||||
};
|
||||
|
||||
#if TRINITY_COMPILER == TRINITY_COMPILER_MICROSOFT
|
||||
#if TRINITY_COMPILER_IS_MICROSOFT
|
||||
template <typename T>
|
||||
struct For<T, std::enable_if_t<std::is_floating_point_v<T>>>
|
||||
{
|
||||
|
||||
@@ -437,7 +437,7 @@ variables_map GetConsoleArguments(int argc, char** argv, fs::path& configFile, f
|
||||
return variablesMap;
|
||||
}
|
||||
|
||||
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
|
||||
#if TRINITY_COMPILER_IS_MICROSOFT
|
||||
#include "WheatyExceptionReport.h"
|
||||
// must be at end of file because of init_seg pragma
|
||||
INIT_CRASH_HANDLER();
|
||||
|
||||
@@ -371,14 +371,14 @@ class TC_GAME_API BaseEntity
|
||||
|
||||
inline BaseEntity* UF::UpdateFieldHolder::GetOwner()
|
||||
{
|
||||
#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
|
||||
#if TRINITY_COMPILER_IS_GNU
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Winvalid-offsetof"
|
||||
#endif
|
||||
|
||||
return reinterpret_cast<BaseEntity*>(reinterpret_cast<std::byte*>(this) - offsetof(BaseEntity, m_values));
|
||||
|
||||
#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
|
||||
#if TRINITY_COMPILER_IS_GNU
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
// This file is automatically generated, DO NOT EDIT
|
||||
|
||||
#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
|
||||
#if TRINITY_COMPILER_IS_GCC
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
#else
|
||||
@@ -10535,7 +10535,7 @@ void PlayerInitiativeComponentData::ClearChangesMask()
|
||||
|
||||
}
|
||||
|
||||
#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
|
||||
#if TRINITY_COMPILER_IS_GCC
|
||||
#pragma GCC diagnostic pop
|
||||
#else
|
||||
#pragma warning(pop)
|
||||
|
||||
@@ -37,7 +37,7 @@ EndScriptData */
|
||||
#include "World.h"
|
||||
#include "WorldSession.h"
|
||||
|
||||
#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
|
||||
#if TRINITY_COMPILER_IS_GCC
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include "RBAC.h"
|
||||
#include "WorldSession.h"
|
||||
|
||||
#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
|
||||
#if TRINITY_COMPILER_IS_GCC
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ EndScriptData */
|
||||
#include "Util.h"
|
||||
#include <iomanip>
|
||||
|
||||
#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
|
||||
#if TRINITY_COMPILER_IS_GCC
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ EndScriptData */
|
||||
#include "WorldSession.h"
|
||||
#include <sstream>
|
||||
|
||||
#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
|
||||
#if TRINITY_COMPILER_IS_GCC
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
#include "World.h"
|
||||
#include "WorldSession.h"
|
||||
|
||||
#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
|
||||
#if TRINITY_COMPILER_IS_GCC
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#include "RBAC.h"
|
||||
#include "WorldSession.h"
|
||||
|
||||
#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
|
||||
#if TRINITY_COMPILER_IS_GCC
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ EndScriptData */
|
||||
|
||||
using namespace Trinity::ChatCommands;
|
||||
|
||||
#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
|
||||
#if TRINITY_COMPILER_IS_GCC
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ EndScriptData */
|
||||
#include "WaypointManager.h"
|
||||
#include "World.h"
|
||||
|
||||
#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
|
||||
#if TRINITY_COMPILER_IS_GCC
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ EndScriptData */
|
||||
#include "World.h"
|
||||
#include "WorldSession.h"
|
||||
|
||||
#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
|
||||
#if TRINITY_COMPILER_IS_GCC
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "RBAC.h"
|
||||
#include "WorldSession.h"
|
||||
|
||||
#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
|
||||
#if TRINITY_COMPILER_IS_GCC
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ EndScriptData */
|
||||
#include <openssl/opensslv.h>
|
||||
#include <numeric>
|
||||
|
||||
#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
|
||||
#if TRINITY_COMPILER_IS_GCC
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ EndScriptData */
|
||||
#include "World.h"
|
||||
#include "WorldSession.h"
|
||||
|
||||
#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
|
||||
#if TRINITY_COMPILER_IS_GCC
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -734,7 +734,7 @@ variables_map GetConsoleArguments(int argc, char** argv, fs::path& configFile, f
|
||||
return vm;
|
||||
}
|
||||
|
||||
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
|
||||
#if TRINITY_COMPILER_IS_MICROSOFT
|
||||
#include "WheatyExceptionReport.h"
|
||||
// must be at end of file because of init_seg pragma
|
||||
INIT_CRASH_HANDLER();
|
||||
|
||||
@@ -1576,7 +1576,7 @@ int main(int argc, char * arg[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
|
||||
#if TRINITY_COMPILER_IS_MICROSOFT
|
||||
#include "WheatyExceptionReport.h"
|
||||
// must be at end of file because of init_seg pragma
|
||||
INIT_CRASH_HANDLER();
|
||||
|
||||
@@ -509,7 +509,7 @@ int main(int argc, char** argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
|
||||
#if TRINITY_COMPILER_IS_MICROSOFT
|
||||
#include "WheatyExceptionReport.h"
|
||||
// must be at end of file because of init_seg pragma
|
||||
INIT_CRASH_HANDLER();
|
||||
|
||||
@@ -112,7 +112,7 @@ Optional<int> HandleArgs(int argc, char* argv[], std::string* src, std::string*
|
||||
return {};
|
||||
}
|
||||
|
||||
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
|
||||
#if TRINITY_COMPILER_IS_MICROSOFT
|
||||
#include "WheatyExceptionReport.h"
|
||||
// must be at end of file because of init_seg pragma
|
||||
INIT_CRASH_HANDLER();
|
||||
|
||||
@@ -736,7 +736,7 @@ int main(int argc, char ** argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
|
||||
#if TRINITY_COMPILER_IS_MICROSOFT
|
||||
#include "WheatyExceptionReport.h"
|
||||
// must be at end of file because of init_seg pragma
|
||||
INIT_CRASH_HANDLER();
|
||||
|
||||
Reference in New Issue
Block a user