Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turning off the "'register' storage class specifier is deprecated" warning

With the recent Xcode 5.1 update we're getting a bunch of new warnings in our code base -
this is apparently related to an updated version of clang that now warns about usages of the register storage class specifier in C++11 sources as it has been deprecated with C++11:

/Users/me/Documents/Sources/boost/boost/log/attributes/attribute_set.hpp:288:9: 'register' storage class specifier is deprecated

Now we'd like to suppress the warning for code that we cannot change - like the BOOST sources in the example above.

I could find the compiler flag to turn the warning on (-Wdeprecated-register) but is there an opposite to disable the warning from the Xcode settings..?

like image 974
Jay Avatar asked Mar 15 '14 10:03

Jay


2 Answers

In general, prepending no- to an option turns it off. So if -Wdeprecated-register enables the warning, then -Wno-deprecated-register should disable it.

Alternatively, on many compilers you can use pragmas (or similar) in your code, to disable warnings while including particular headers while leaving them enabled for your own code. They are compiler-specific; for Clang, it's something like

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-register"
#include "dodgy.hpp"
#pragma clang diagnostic pop

(For GCC, the pragmas are the same, only replacing clang with GCC. I don't know about any other compilers.)

like image 165
Mike Seymour Avatar answered Oct 04 '22 04:10

Mike Seymour


Suppressing the warning is the wrong tool here. Use the -isystem flag when including code that is not yours and it will generate no warnings in that code.

like image 20
R. Martinho Fernandes Avatar answered Oct 04 '22 04:10

R. Martinho Fernandes