2

I have my build configured to give compiler warnings for unused variables. I use scoped_locks liberally in my code, and am curious as to how local instances of scoped locks circumvent the warning.

So my question is, why do boost::scoped_lock's not generate an unused variable compiler warning?

Example code:

void myFunc() {
  boost::mutex::scoped_lock lock(_mutex) // no compiler warning
  var a;  // Compiler warning
}
MM.
  • 4,224
  • 5
  • 37
  • 74
  • 2
    I think this is a duplicate of http://stackoverflow.com/questions/5302848/g-does-not-show-a-unused-warning or something similar, since I found it kind of hard to find the answer in what's currently linked. – Ivan Vergiliev May 16 '14 at 15:46
  • You're right. This has been answered. – MM. May 16 '14 at 16:01
  • The link provided by Ivan Vergiliev has a better answer than the duplicate issue cited by dasblinkenlight. – MM. May 16 '14 at 16:04

0 Answers0