diff options
author | Shea Levy <shea@shealevy.com> | 2014-10-20 12:15:50 -0400 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2015-05-11 17:37:20 +0200 |
commit | bed17f40fce27e1a31f70957b1d0dd912b58700d (patch) | |
tree | 6e5968eab59a2dbdcf796aaaf1d777ac5e120450 | |
parent | ee8601cac4b353e551b238f546a0e7e8fcdcd3be (diff) | |
download | guix-bed17f40fce27e1a31f70957b1d0dd912b58700d.tar.gz |
Fix build on gcc < 4.7
-rw-r--r-- | nix/libutil/types.hh | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/nix/libutil/types.hh b/nix/libutil/types.hh index 906a959e30..160884ee1a 100644 --- a/nix/libutil/types.hh +++ b/nix/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); |