fixed compiler warning 'extern "C" void(*)(int) in call to std::signal' using SunStudio

This commit is contained in:
Wiscy 2016-12-01 10:18:05 +01:00 committed by Wiscy
parent c52d2fe383
commit 13071a875c
2 changed files with 23 additions and 0 deletions

View File

@ -125,6 +125,7 @@
#define CATCH_INTERNAL_CONFIG_VARIADIC_MACROS #define CATCH_INTERNAL_CONFIG_VARIADIC_MACROS
#define CATCH_INTERNAL_SUNPRO_CC_NON_COMPLIANT_STL #define CATCH_INTERNAL_SUNPRO_CC_NON_COMPLIANT_STL
#define CATCH_INTERNAL_EXTERNAL_C_SIGNAL_HANDLER
// Tested OK with: // Tested OK with:
// __SUNPRO_CC 0x580 // __SUNPRO_CC 0x580
// __SUNPRO_CC 0x5110 // __SUNPRO_CC 0x5110

View File

@ -38,6 +38,13 @@ namespace Catch {
#include <signal.h> #include <signal.h>
#ifdef CATCH_INTERNAL_EXTERNAL_C_SIGNAL_HANDLER
extern "C"
{
void catch_c_signal_handler (int sig);
}
#endif // CATCH_INTERNAL_EXTERNAL_C_SIGNAL_HANDLER
namespace Catch { namespace Catch {
struct SignalDefs { int id; const char* name; }; struct SignalDefs { int id; const char* name; };
@ -62,7 +69,13 @@ namespace Catch {
FatalConditionHandler() : m_isSet( true ) { FatalConditionHandler() : m_isSet( true ) {
for( std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i ) for( std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i )
{
#ifdef CATCH_INTERNAL_EXTERNAL_C_SIGNAL_HANDLER
signal( signalDefs[i].id, catch_c_signal_handler );
#else
signal( signalDefs[i].id, handleSignal ); signal( signalDefs[i].id, handleSignal );
#endif // CATCH_INTERNAL_EXTERNAL_C_SIGNAL_HANDLER
}
} }
~FatalConditionHandler() { ~FatalConditionHandler() {
reset(); reset();
@ -80,6 +93,15 @@ namespace Catch {
} // namespace Catch } // namespace Catch
#ifdef CATCH_INTERNAL_EXTERNAL_C_SIGNAL_HANDLER
extern "C"
{
void catch_c_signal_handler (int sig)
{
Catch::FatalConditionHandler::handleSignal(sig);
}
}
#endif // CATCH_INTERNAL_EXTERNAL_C_SIGNAL_HANDLER
#endif // not Windows #endif // not Windows
#endif // TWOBLUECUBES_CATCH_FATAL_CONDITION_H_INCLUDED #endif // TWOBLUECUBES_CATCH_FATAL_CONDITION_H_INCLUDED