From 2850032d9e442f77cec9e6ebac90ac09bd645db8 Mon Sep 17 00:00:00 2001 From: eroen Date: Sun, 26 May 2013 10:36:17 +0200 Subject: [PATCH 1/2] libc++ fixes: avcodec/avformat workaround With libc++, string includes stdint.h, which breaks the fragile avformat.h workaround, which depends on __STDC_CONSTANT_MACROS being defined before stdint.h is included. Moving the string inclusion after that eyesore shouldn't break anything. --- apps/openmw/mwsound/ffmpeg_decoder.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwsound/ffmpeg_decoder.hpp b/apps/openmw/mwsound/ffmpeg_decoder.hpp index 32b2797ed..a5e5b5083 100644 --- a/apps/openmw/mwsound/ffmpeg_decoder.hpp +++ b/apps/openmw/mwsound/ffmpeg_decoder.hpp @@ -1,8 +1,6 @@ #ifndef GAME_SOUND_FFMPEG_DECODER_H #define GAME_SOUND_FFMPEG_DECODER_H -#include - // FIXME: This can't be right? The headers refuse to build without UINT64_C, // which only gets defined in stdint.h in either C99 mode or with this macro // defined... @@ -14,6 +12,8 @@ extern "C" #include } +#include + #include "sound_decoder.hpp" From 886bc7e2f6563aaa6bd01608991dfec54a95a488 Mon Sep 17 00:00:00 2001 From: eroen Date: Sun, 26 May 2013 12:44:10 +0200 Subject: [PATCH 2/2] libc++ fixes: don't rely on tr1 libc++ doesn't ship tr1, but ships unordered_map as it is part of c++11. Since this is the only tr1 header used in openmw, add a check for c++11 unordered_map and fallback to tr1 unordered_map if it's not found. --- CMakeLists.txt | 6 ++++++ components/files/configurationmanager.hpp | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b989297b3..43415c953 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -181,6 +181,12 @@ if (UNIX AND NOT APPLE) find_package (Threads) endif() +include (CheckIncludeFileCXX) +check_include_file_cxx(unordered_map HAVE_UNORDERED_MAP) +if (HAVE_UNORDERED_MAP) + add_definitions(-DHAVE_UNORDERED_MAP) +endif () + set(BOOST_COMPONENTS system filesystem program_options thread date_time wave) diff --git a/components/files/configurationmanager.hpp b/components/files/configurationmanager.hpp index 9056e792d..765f1cebf 100644 --- a/components/files/configurationmanager.hpp +++ b/components/files/configurationmanager.hpp @@ -3,6 +3,8 @@ #ifdef _WIN32 #include +#elif defined HAVE_UNORDERED_MAP +#include #else #include #endif @@ -48,7 +50,11 @@ struct ConfigurationManager typedef Files::FixedPath<> FixedPathType; typedef const boost::filesystem::path& (FixedPathType::*path_type_f)() const; - typedef std::tr1::unordered_map TokensMappingContainer; + #if defined HAVE_UNORDERED_MAP + typedef std::unordered_map TokensMappingContainer; + #else + typedef std::tr1::unordered_map TokensMappingContainer; + #endif void loadConfig(const boost::filesystem::path& path, boost::program_options::variables_map& variables,