Rapptz / sol

A C++11 Lua wrapper

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Programmatically ignore warnings.

Rapptz opened this issue · comments

There are some warnings that cause issues w.r.t. compilation (mainly Clang). Through the use of #pragma and _Pragma you could programmatically disable some warnings that just make things a headache.

Example:

#define STRINGIZE_PRAGMA(x) _Pragma(#x)

#if defined(__clang__)
#define PRAGMA(x) STRINGIZE_PRAGMA (clang x)
#elif defined (__GNUC__)
#define PRAGMA(x) STRINGIZE_PRAGMA (GCC x)
#endif

PRAGMA(diagnostic push)
PRAGMA(diagnostic ignored "-Wwhatever")
// some code here
PRAGMA(diagnostic pop)

Some candidates for programmatic removal include:

  • '-Wno-unused-value'
  • '-Wno-constexpr-not-const'

Probably others as time goes on.

Not a clue if there's an MSVC version of this. Will find out.

MSVC is easier.

#pragma warning(disable : number)

To 'pop' you have to do

#pragma warning(default : number)

That's not a name though, is it?

No, no names, just the warning number. e.g. C4244 will be 4244.

Is there a particular reason for mangling warnings? I was under the impression we had a warningless build.

They're annoying. We have a warningless build because of the way the flags are set up.