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..?

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.)


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.


This also works

#if __cplusplus > 199711L
#define register      // Deprecated in C++11.
#endif  // #if __cplusplus > 199711L

Need Your Help

Thread safe of state machine gems in multi-tenant Rail app

ruby-on-rails ruby multithreading workflow aasm

There are a few popular Ruby state machine gems such as geekq/workflow and aasm. Are they thread safe in multi-tenant Rails 4.2 application?

Cloning existing sheet and adding information inside it

php phpexcel

I have 2 sheets in my .xlsx file. i need to open sheet number 1 and clone it with data as i do foreach loop.