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

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


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