Allow including LibCarla headers multiple times in UE4

This commit is contained in:
nsubiron 2018-09-18 14:42:34 +02:00
parent 13b9723c46
commit 3bd67d2fdf
3 changed files with 33 additions and 34 deletions

View File

@ -5,20 +5,7 @@
// For a copy, see <https://opensource.org/licenses/MIT>. // For a copy, see <https://opensource.org/licenses/MIT>.
#ifndef LIBCARLA_INCLUDED_DISABLE_UE4_MACROS_HEADER #ifndef LIBCARLA_INCLUDED_DISABLE_UE4_MACROS_HEADER
# define LIBCARLA_INCLUDED_DISABLE_UE4_MACROS_HEADER #define LIBCARLA_INCLUDED_DISABLE_UE4_MACROS_HEADER
#else
# error disable-ue4-macros.h should only be included once!
#endif // LIBCARLA_INCLUDED_DISABLE_UE4_MACROS_HEADER
#pragma push_macro("check")
#undef check
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wmissing-braces"
#endif
#define LIBCARLA_INCLUDED_FROM_UE4
#ifndef BOOST_ERROR_CODE_HEADER_ONLY #ifndef BOOST_ERROR_CODE_HEADER_ONLY
# define BOOST_ERROR_CODE_HEADER_ONLY # define BOOST_ERROR_CODE_HEADER_ONLY
@ -35,6 +22,22 @@
# endif // __cpp_coroutines # endif // __cpp_coroutines
#endif // defined(__clang__) #endif // defined(__clang__)
// NOTE(Andrei): disable warning generated by undefined macros
// __GNUC__, __GNUC_MINOR__
// MSGPACK_ARCH_AMD64
// DBG, BETA, OFFICIAL_BUILD
// NTDDI_WIN7SP1
// _APISET_RTLSUPPORT_VER
// _APISET_INTERLOCKED_VER
// _APISET_SECURITYBASE_VER
// _WIN32_WINNT_WINTHRESHOLD
// NOTE(Andrei): Macros to detect which compiler is
// http://nadeausoftware.com/articles/2012/10/c_c_tip_how_detect_compiler_name_and_version_using_compiler_predefined_macros
#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable: 4668 4191)
#endif
namespace boost { namespace boost {
static inline void throw_exception(const std::exception &e) { static inline void throw_exception(const std::exception &e) {
@ -43,5 +46,17 @@ namespace boost {
} // namespace boost } // namespace boost
#endif // LIBCARLA_INCLUDED_DISABLE_UE4_MACROS_HEADER
#define LIBCARLA_INCLUDED_FROM_UE4
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wmissing-braces"
#endif
#pragma push_macro("TEXT") #pragma push_macro("TEXT")
#undef TEXT #undef TEXT
#pragma push_macro("check")
#undef check

View File

@ -7,6 +7,10 @@
#pragma pop_macro("check") #pragma pop_macro("check")
#pragma pop_macro("TEXT") #pragma pop_macro("TEXT")
#if defined(_MSC_VER)
# pragma warning(pop)
#endif
#if defined(__clang__) #if defined(__clang__)
# pragma clang diagnostic pop # pragma clang diagnostic pop
#endif #endif

View File

@ -11,23 +11,6 @@
#include "GameFramework/SpectatorPawn.h" #include "GameFramework/SpectatorPawn.h"
// NOTE(Andrei): disable warning generated by undefined macros
// __GNUC__, __GNUC_MINOR__
// MSGPACK_ARCH_AMD64
// DBG, BETA, OFFICIAL_BUILD
// NTDDI_WIN7SP1
// _APISET_RTLSUPPORT_VER
// _APISET_INTERLOCKED_VER
// _APISET_SECURITYBASE_VER
// _WIN32_WINNT_WINTHRESHOLD
// NOTE(Andrei): Macros to detect which compiler is
//http://nadeausoftware.com/articles/2012/10/c_c_tip_how_detect_compiler_name_and_version_using_compiler_predefined_macros
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable: 4668 4191)
#endif
#include <compiler/disable-ue4-macros.h> #include <compiler/disable-ue4-macros.h>
#include <carla/Version.h> #include <carla/Version.h>
#include <carla/rpc/Actor.h> #include <carla/rpc/Actor.h>
@ -39,9 +22,6 @@
#include <carla/streaming/Server.h> #include <carla/streaming/Server.h>
#include <compiler/enable-ue4-macros.h> #include <compiler/enable-ue4-macros.h>
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
#include <vector> #include <vector>
// ============================================================================= // =============================================================================