How to disable warning for C++ local variable with non trival destructor never used for a specific type?

We like the warning that a local variable with a non trival destructor is never used. However there are a couple of cases were this check create false reports:

For example CWaitCursor, lock classes, etc. 

Is there are way to disable this warning for certain types? Preferable somewhere in the shared team settings?

Using the comment CppLocalVariableWithNonTrivialDtorIsNeverUsed to disable the warning works, but we don't like to sprinkle our code with these kind of comments.

Comment actions Permalink


You need to use the [[rscpp::guard]] attribute on the declaration of the class to suppress this inspection ( If your compiler complains about an unknown attribute, you could wrap the attribute inside #ifdef __RESHARPER__ ... #endif.

Comment actions Permalink

Hi Igor,

Thanks for the quick response. Your solution works super. I was also able to suppress this warning for external (MFC) classes by adding a forward definition in stdafx.h:

#ifdef __RESHARPER__
class [[rscpp::guard]] CWaitCursor;
and indeed my compiler (Microsoft VC++ 15.4.0) complains about the [[rscpp::guard]] attribute.
Comment actions Permalink

Great, this way you can probably put all forward declarations with ReSharper-specific annotations inside a single #ifdef __RESHARPER__.


Please sign in to leave a comment.