Using g ++ how to abandon virtual class class functions

I seem to be having problems getting obsolete print alerts as functions are declared as virtual. I am using "g ++ (GCC) 4.1.1 20061011 (Red Hat 4.1.1-30)". My research shows that in gcc 4.x there may be problems regarding the obsolescence of pure virtual functions (i.e. class bueller {virtual int cameron () = 0;};) but not ... I would suggest that you would called them regular ... virtual functions. We are just on the same page ...

foo.h

class Foo { void Foo_A() __attribute__((deprecated)); //non-virtual virtual void Foo_B() __attribute__((deprecated)); //virtual virtual void Foo_C() __attribute__((deprecated)) = 0; //pure virtual }; 

Say I compiled this, the foo.cpp file and some main.cpp file using g ++.

1) Everything that uses Foo_A () will actually display a warning.

2) Everything that uses Foo_B () does not show a warning.

3) Everything that Foo inherits, implements Foo_C, and then uses it, no warning is displayed.

Number 1: it works, no problem.

Number 3: seems like a known bug / feature .. anything ..

There seems to be no explanation for No. 2. Perhaps this is due to number 3, although nothing that I found does not mention this.

Does anyone know if I have missed something regarding the normal functions of a virtual class class that I want to denounce?

BTW: -Wno-deprecate is NOT included in my makefiles.

+4
source share
3 answers

Given this program:

 struct Foo { virtual void Foo_B() __attribute__((deprecated)); //virtual }; struct DerivedFoo : public Foo { }; int main() { DerivedFoo d; d.Foo_B(); Foo &f = d; f.Foo_B(); } void Foo::Foo_B() {} 

On CentOS 5.2 (gcc 4.1.2 version 20080704 (Red Hat 4.1.2-44)) I get the same output that you describe:

 g++ deprecate.cc -o deprecate deprecate.cc: In function 'int main()': deprecate.cc:14: warning: 'Foo_B' is deprecated (declared at deprecate.cc:3) 

But, on Ubuntu 10.04.1 (gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5)), I get the expected result:

 g++ deprecate.cc -o deprecate deprecate.cc: In function 'int main()': deprecate.cc:14: warning: 'virtual void Foo::Foo_B()' is deprecated (declared at deprecate.cc:3) deprecate.cc:16: warning: 'virtual void Foo::Foo_B()' is deprecated (declared at deprecate.cc:3) 

So, I assume that the compiler error has been fixed.

+1
source

Are you calling Foo_B () / Foo_C () with a pointer / link to Foo or a derived class? If you are using a derived class, it seems that you should also note the methods that are deprecated in it, or you will get a description that you are describing.

0
source

Google shows an old discussion in this section on the Debian list. But nothing else comes up on this topic. Try talking about the distribution (RedHat lists, in this case).

0
source

All Articles