views:

262

answers:

1

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?

+3  A: 

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.

Mykola Golubyev
It would be nice not to have to switch it off for the whole library though...
Dan