How to 'hide' spurious "declared but never used" warnings?

Posted by Roddy on Stack Overflow See other posts from Stack Overflow or by Roddy
Published on 2010-04-26T09:39:54Z Indexed on 2010/04/26 9:43 UTC
Read the original article Hit count: 247

Filed under:
|
|

I'm using the C++Builder compiler which has a minor bug that certain static const items from system header files can cause spurious "xyzzy is declared but never used" warnings.

I'm trying to get my code 100% warning free, so want a way of masking these particular warnings (note - but not by simply turning off the warning!)

Also, I can't modify the header files. I need a way of 'faking' the use of the items, preferably without even knowing their type.

As an example, adding this function to my .cpp modules fixes warnings for these four items, but it seems a bit 'ad-hoc'. Is there a better and preferably self-documenting way of doing this?

static int fakeUse()
{
  return OneHour + OneMinute + OneSecond + OneMillisecond;
}

© Stack Overflow or respective owner

Related posts about c++builder

Related posts about c++