diff options
author | Shea Levy <shea@shealevy.com> | 2014-10-20 12:15:50 -0400 |
---|---|---|
committer | Shea Levy <shea@shealevy.com> | 2014-10-20 12:15:50 -0400 |
commit | 6062b121605b298c73ddf11688b075ed78a46df2 (patch) | |
tree | 52ea9d76a92e7a159c43e781ad12438e431234bf | |
parent | f040159f77e518e5eda87a0c092e6c20d87a572b (diff) |
Fix build on gcc < 4.7
-rw-r--r-- | src/libexpr/eval.hh | 3 | ||||
-rw-r--r-- | src/libutil/types.hh | 13 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index daf53846f..51ab1b1e8 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -340,6 +340,9 @@ struct InvalidPathError : EvalError { Path path; InvalidPathError(const Path & path); +#ifdef EXCEPTION_NEEDS_THROW_SPEC + ~InvalidPathError() throw () { }; +#endif }; /* Realise all paths in `context' */ diff --git a/src/libutil/types.hh b/src/libutil/types.hh index 906a959e3..160884ee1 100644 --- a/src/libutil/types.hh +++ b/src/libutil/types.hh @@ -8,6 +8,15 @@ #include <boost/format.hpp> +/* Before 4.7, gcc's std::exception uses empty throw() specifiers for + * its (virtual) destructor and what() in c++11 mode, in violation of spec + */ +#ifdef __GNUC__ +#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7) +#define EXCEPTION_NEEDS_THROW_SPEC +#endif +#endif + namespace nix { @@ -39,8 +48,12 @@ protected: public: unsigned int status; // exit status BaseError(const FormatOrString & fs, unsigned int status = 1); +#ifdef EXCEPTION_NEEDS_THROW_SPEC ~BaseError() throw () { }; const char * what() const throw () { return err.c_str(); } +#else + const char * what() const noexcept { return err.c_str(); } +#endif const string & msg() const { return err; } const string & prefix() const { return prefix_; } BaseError & addPrefix(const FormatOrString & fs); |