From: Uwe Hermann Date: Sun, 22 Jul 2018 15:07:26 +0000 (+0200) Subject: Fix multiple C++ bindings warnings with gcc 8. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=0875f11de44e337397d13af3daf616ec48df6b76;p=libsigrok.git Fix multiple C++ bindings warnings with gcc 8. bindings/cxx/classes.cpp: In function ‘int sigrok::call_log_callback(void*, int, const char*, __va_list_tag*)’: bindings/cxx/classes.cpp:242:17: warning: catching polymorphic type ‘class sigrok::Error’ by value [-Wcatch-value=] } catch (Error e) { ^ In file included from bindings/cxx/classes.cpp:1667: bindings/cxx/enums.cpp: In static member function ‘static Glib::VariantBase sigrok::ConfigKey::parse_string(std::__cxx11::string, sr_datatype)’: bindings/cxx/enums.cpp:789:13: warning: catching polymorphic type ‘class std::invalid_argument’ by value [-Wcatch-value=] } catch (invalid_argument) { ^~~~~~~~~~~~~~~~ bindings/cxx/enums.cpp:804:13: warning: catching polymorphic type ‘class std::invalid_argument’ by value [-Wcatch-value=] } catch (invalid_argument) { ^~~~~~~~~~~~~~~~ --- diff --git a/bindings/cxx/ConfigKey_methods.cpp b/bindings/cxx/ConfigKey_methods.cpp index ee0a74eb..9c3668ff 100644 --- a/bindings/cxx/ConfigKey_methods.cpp +++ b/bindings/cxx/ConfigKey_methods.cpp @@ -90,7 +90,7 @@ Glib::VariantBase ConfigKey::parse_string(string value, enum sr_datatype dt) case SR_T_FLOAT: try { variant = g_variant_new_double(stod(value)); - } catch (invalid_argument) { + } catch (invalid_argument&) { throw Error(SR_ERR_ARG); } break; @@ -105,7 +105,7 @@ Glib::VariantBase ConfigKey::parse_string(string value, enum sr_datatype dt) case SR_T_INT32: try { variant = g_variant_new_int32(stoi(value)); - } catch (invalid_argument) { + } catch (invalid_argument&) { throw Error(SR_ERR_ARG); } break; diff --git a/bindings/cxx/classes.cpp b/bindings/cxx/classes.cpp index bf826e3c..5bc5dc2f 100644 --- a/bindings/cxx/classes.cpp +++ b/bindings/cxx/classes.cpp @@ -239,7 +239,7 @@ static int call_log_callback(void *cb_data, int loglevel, try { (*callback)(LogLevel::get(loglevel), message.get()); - } catch (Error e) { + } catch (Error &e) { return e.result; }