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:
Martin Kröning
2019-08-20 18:19:52 -07:00
committed by Colby Klein
parent 4db93fc774
commit 8ab7c7fab9
5 changed files with 42 additions and 21 deletions
+20 -10
View File
@@ -46,18 +46,28 @@ 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
* which case it'll be called if any exceptions are thrown at all. */
#include <cxxabi.h>
void UnexpectedExceptionHandler()
{
type_info *pException = abi::__cxa_current_exception_type();
char const *pName = pException->name();
int iStatus = -1;
char *pDem = abi::__cxa_demangle( pName, 0, 0, &iStatus );
const RString error = ssprintf("Unhandled exception: %s", iStatus? pName:pDem);
std::exception_ptr exptr = std::current_exception();
try
{
std::rethrow_exception(exptr);
}
catch (std::exception &ex)
{
#if defined(CRASH_HANDLER)
sm_crash( error );
const RString error = ssprintf("Unhandled exception: %s", ex.what());
sm_crash( error );
#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()
@@ -68,7 +78,7 @@ void InstallExceptionHandler()
/*
* (c) 2003-2004 Glenn Maynard
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -78,7 +88,7 @@ void InstallExceptionHandler()
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF