I have C++ code that used to compile (and work), now I get lots of warnings. This happened after I did a dist-upgrade to Ubuntu-Mate.
warning: dynamic exception specifications are deprecated in C++11
It happens on lines as simple as this (in a header):
static Value getPriorityValue(const std::string& priorityName)
throw(std::invalid_argument);
I got 2545 warning related to this! Is there anyway to tell the compiler to ignore this warning? What is the easiest way to make changes to the code.
Most of the errors are in a 3rd party package so I don't want to make too many modifications to this package.
I do have the -std=c++11 flag on in my compiler.
The dynamic exception specification, or throw (optional_type_list) specification, was deprecated in C++11 and removed in C++17, except for throw (), which is an alias for noexcept (true). This exception specification was designed to provide summary information about what exceptions can be thrown out of a function, ...
Explicit dynamic specification allowed specifying one or more types for exception that might be thrown by a function. In 1978, Brian Kernighan and Dennis Ritchie published the first edition of The C Programming Language. It's a very reasonable question. P1018: Cable sold today under any RG label is unlikely to meet military MIL-C-17 specifications.
Privacy policy. Thank you. Exception specifications are a C++ language feature that indicate the programmer's intent about the exception types that can be propagated by a function. You can specify that a function may or may not exit by an exception by using an exception specification.
And new standard and have been removed from the C++ Standardization Committee has finished meeting. With dynamic exceptions when they were proposed sure you have a product-specific question please on. Separate loops than in a combined loop C with Classes '', the set iso c++17 does not allow dynamic exception specifications all types the.
You should remove or comment out these exception specifications wherever you can1, e.g.:
static Value getPriorityValue(const std::string& priorityName);
static Value getPriorityValue(const std::string& priorityName) /* throw(...) */;
You can use the -Wno-deprecated
option to turn-off depreciation warnings for places where you cannot edit the code. I would recommend only using it when compiling third-party libraries. If you need to include a third-party header that raise such warning, you could do2:
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated"
#include "thirdparty.h"
#pragma GCC diagnostic pop
This should work with both gcc
and clang
and will only disable -Wdeprecated
for specific includes.
1 Dynamic exception specifications are deprecated since C++11, and are illegal since C++17, so you might want to get rid of them and upgrade third-party libraries you are using as soon as possible.
2 If you include these headers using a -I
argument, you could switch to -isystem
to disable all warnings for these headers, as mentioned by @Yakk - Adam Nevraumont. See also How to suppress GCC warnings from library headers?.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With