c++ - How do I disable Unused Variable warnings in Eclipse in minGW? -


how can disable following warning in c++ in mingw?

warning: unused variable 'x' [-wunused-variable] 

in eclipse cdt, can't locate warning number:

../src/subfolder/classtwo.cpp:20:8: warning: unused variable 'x' [-wunused-variable] 

i tried doing this:

#pragma warning(push) #pragma warning(disable: ?) //which number? #include "subfolder/classtwo.h" #pragma warning(pop) 

but didn't work.

my questions:

  1. how can warning number of in eclipse cdt?
  2. how should pragma directive written?

it looks output clang. can achieve same using clang using approach outlined here: http://clang.llvm.org/docs/usersmanual.html#controlling-diagnostics-via-pragmas:

#pragma clang diagnostic push #pragma clang diagnostic ignored "-wunused-variable" #include "subfolder/classtwo.h"     #pragma clang diagnostic pop 

if that's source file, fix warning.

for gcc, can use this: selectively disable gcc warnings part of translation unit?

#pragma gcc diagnostic push #pragma gcc diagnostic ignored "-wunused-variable" #include "subfolder/classtwo.h" #pragma gcc diagnostic pop 

of course, leave amount of pragma noise -- debatable if bad thing =)


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -