Is there a way to disambiguous there two variable declaration (RAII) (local variable never used)

Hi, 


This is an MFC example, but we have similar C++ RAII constructs (like lock guards) that generate the same warnings.


Is there a way to catch the unused variable s  without catching the wait  constructs like the CWaitCursor ? 

Both generate a warning "Local variable .. is never used, but may have side effects in its destructor"


void F()
{
CWaitCursor wait;
CString s;

// do something without wait or s 
}

Thanks
Max.

 

2 comments
Comment actions Permalink

Hello,

You can mark the guard classes with the [[rscpp::guard]] C++ attribute to silence the inspection. If the compiler complains about an unknown attribute, you can use the __RESHARPER__ macro like this:

#ifdef __RESHARPER__
class [[rscpp::guard]] CWaitCursor;
#endif
1
Comment actions Permalink

Awesome, I also found the similar question with a good solution 

0

Please sign in to leave a comment.