2

I have a section of code that uses a Boost library that results in a lot of these type of warning messages:

class x has virtual functions but non-virtual destructor

Using g++ 4.1.2, how do I temporarily disable warnings for this codeblock then enable them again after it.

Everything I try (pragma gcc diagnostic, etc) seems to only be supported by a later version of g++.

How do I suppress just these warnings?

4
  • Fixing the warnings in your code is not an option? The condition (virtual functions but non-virtual destructor) usually points to a design error...
    – DevSolar
    Nov 18, 2009 at 11:47
  • It's not in my code, it's in boost...
    – Dan
    Nov 18, 2009 at 11:54
  • 1
    Out of interest, which Boost library is this? And which version? Nov 18, 2009 at 13:23
  • It's in Boost logging. Non-virtual destructors don't always point to a design error (gotw.ca/publications/mill18.htm - guideline 4).
    – Dan
    Nov 19, 2009 at 12:33

1 Answer 1

3

Take a look at the -Wno-non-virtual-dtor.

You can restrict this option to affect only certain files.
Can you move your "bad" code to separate c++ file? If so, turn this option only for that file.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.