Skip to content

Commit

Permalink
work around GCC 4.8 compiler errors with objects used in dinit()
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Aug 2, 2023
1 parent baccbc6 commit ab88131
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
13 changes: 13 additions & 0 deletions test/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,17 @@ class PreprocessorHelper
#define dinit(T, ...) \
([&] { T ${}; __VA_ARGS__; return $; }())

#if (defined(__GNUC__) && (__GNUC__ >= 5)) || defined(__clang__)
// work around Clang compilation error
// error: default member initializer for 'y' needed within definition of enclosing class 'X' outside of member functions
// work around GCC compilation error
// error: default member initializer for ‘x::y::z’ required before the end of its enclosing class
// see https://stackoverflow.com/questions/53408962
#define DINIT_NOEXCEPT noexcept
#else
// work around GCC 4.8 compilation error
// error: function 'x()' defaulted on its first declaration with an exception-specification that differs from the implicit declaration 'x()'
#define DINIT_NOEXCEPT
#endif

#endif // helpersH
2 changes: 1 addition & 1 deletion test/testprocessexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class TestProcessExecutor : public TestFixture {

struct CheckOptions
{
CheckOptions() noexcept = default;
CheckOptions() DINIT_NOEXCEPT = default;
SHOWTIME_MODES showtime = SHOWTIME_MODES::SHOWTIME_NONE;
const char* plistOutput = nullptr;
std::vector<std::string> filesList;
Expand Down
2 changes: 1 addition & 1 deletion test/testsingleexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class TestSingleExecutorBase : public TestFixture {

struct CheckOptions
{
CheckOptions() noexcept = default;
CheckOptions() DINIT_NOEXCEPT = default;
SHOWTIME_MODES showtime = SHOWTIME_MODES::SHOWTIME_NONE;
const char* plistOutput = nullptr;
std::vector<std::string> filesList;
Expand Down
2 changes: 1 addition & 1 deletion test/testthreadexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class TestThreadExecutor : public TestFixture {

struct CheckOptions
{
CheckOptions() noexcept = default;
CheckOptions() DINIT_NOEXCEPT = default;
SHOWTIME_MODES showtime = SHOWTIME_MODES::SHOWTIME_NONE;
const char* plistOutput = nullptr;
std::vector<std::string> filesList;
Expand Down

0 comments on commit ab88131

Please sign in to comment.