5_1-new: Fix building with clang/clang++ (#1866)
* Have clang and libc++ working.
If any clang users run into problems, remember to have libc++ and libc++abi set up.
Fixes
stepmania/src/arch/ArchHooks/ArchHooks.h:37:27: error:
variable has incomplete type 'tm'
virtual void SetTime( tm ) { }
^
/usr/include/wchar.h:83:8: note: forward declaration of 'tm'
struct tm;
^
* Add noexcept to swap.
See https://github.com/stepmania/stepmania/commit/e860773799f01d02f281c8c39421e7e34658788d#commitcomment-32674320
* Use standard c++11 for handling unexpected exceptions
The cxxabi.h header can make linking difficult.
This commit is contained in:
committed by
Colby Klein
parent
4db93fc774
commit
8ab7c7fab9
@@ -32,6 +32,8 @@ matrix:
|
|||||||
- libxtst-dev
|
- libxtst-dev
|
||||||
- libxrandr-dev
|
- libxrandr-dev
|
||||||
- libglew-dev
|
- libglew-dev
|
||||||
|
- libc++-dev
|
||||||
|
- libstdc++-4.8-dev
|
||||||
|
|
||||||
-
|
-
|
||||||
env: CXX_COMPILER=clang++-3.6 CC_COMPILER=clang-3.6 BUILD_TYPE=Release WITH_FFMPEG=ON WITH_FFMPEG_JOBS=1
|
env: CXX_COMPILER=clang++-3.6 CC_COMPILER=clang-3.6 BUILD_TYPE=Release WITH_FFMPEG=ON WITH_FFMPEG_JOBS=1
|
||||||
|
|||||||
@@ -386,6 +386,7 @@ else() # Linux
|
|||||||
sm_add_compile_flag("${SM_EXE_NAME}" "-stdlib=libc++")
|
sm_add_compile_flag("${SM_EXE_NAME}" "-stdlib=libc++")
|
||||||
set_target_properties("${SM_EXE_NAME}"
|
set_target_properties("${SM_EXE_NAME}"
|
||||||
PROPERTIES LINK_FLAGS "-stdlib=libc++")
|
PROPERTIES LINK_FLAGS "-stdlib=libc++")
|
||||||
|
sm_add_compile_flag("jsoncpp" "-stdlib=libc++")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
+7
-1
@@ -382,7 +382,13 @@ public:
|
|||||||
/** @brief Allow a quick way to swap notedata. */
|
/** @brief Allow a quick way to swap notedata. */
|
||||||
namespace std
|
namespace std
|
||||||
{
|
{
|
||||||
template<> inline void swap<NoteData>( NoteData &nd1, NoteData &nd2 ){ nd1.swap( nd2 ); }
|
template<> inline void swap<NoteData>( NoteData &nd1, NoteData &nd2 )
|
||||||
|
#if !defined(_MSC_VER)
|
||||||
|
noexcept(is_nothrow_move_constructible<NoteData>::value && is_nothrow_move_assignable<NoteData>::value)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
nd1.swap( nd2 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#ifndef ARCH_HOOKS_H
|
#ifndef ARCH_HOOKS_H
|
||||||
#define ARCH_HOOKS_H
|
#define ARCH_HOOKS_H
|
||||||
|
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
struct lua_State;
|
struct lua_State;
|
||||||
class ArchHooks
|
class ArchHooks
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -46,19 +46,29 @@ extern "C" void __assert_perror_fail( int errnum, const char *file, unsigned int
|
|||||||
|
|
||||||
/* Catch unhandled C++ exceptions. Note that this works in g++ even with -fno-exceptions, in
|
/* Catch unhandled C++ exceptions. Note that this works in g++ even with -fno-exceptions, in
|
||||||
* which case it'll be called if any exceptions are thrown at all. */
|
* which case it'll be called if any exceptions are thrown at all. */
|
||||||
#include <cxxabi.h>
|
|
||||||
void UnexpectedExceptionHandler()
|
void UnexpectedExceptionHandler()
|
||||||
{
|
{
|
||||||
type_info *pException = abi::__cxa_current_exception_type();
|
std::exception_ptr exptr = std::current_exception();
|
||||||
char const *pName = pException->name();
|
try
|
||||||
int iStatus = -1;
|
{
|
||||||
char *pDem = abi::__cxa_demangle( pName, 0, 0, &iStatus );
|
std::rethrow_exception(exptr);
|
||||||
|
}
|
||||||
const RString error = ssprintf("Unhandled exception: %s", iStatus? pName:pDem);
|
catch (std::exception &ex)
|
||||||
|
{
|
||||||
#if defined(CRASH_HANDLER)
|
#if defined(CRASH_HANDLER)
|
||||||
|
const RString error = ssprintf("Unhandled exception: %s", ex.what());
|
||||||
sm_crash( error );
|
sm_crash( error );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
// TODO: Don't throw anything not subclassing std::exception
|
||||||
|
catch(...)
|
||||||
|
{
|
||||||
|
#if defined(CRASH_HANDLER)
|
||||||
|
const RString error = ssprintf("Unknown exception.");
|
||||||
|
sm_crash( error );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void InstallExceptionHandler()
|
void InstallExceptionHandler()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user