c++ - using g++, how to deprecate virtual class member functions -


i seem having trouble getting deprecated warnings print out, functions declared virtual. i'm using "g++ (gcc) 4.1.1 20061011 (red hat 4.1.1-30)." research shows there might problems in gcc 4.x regarding deprecating pure virtual functions(i.e. class bueller{ virtual int cameron()=0;};), not... i'd guess you'd call them regular... virtual functions. we're on 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 compiled this, foo.cpp file , main.cpp file using g++.

1)anything uses foo_a() indeed show warning.

2)anything uses foo_b() not show warning.

3)anything inherits foo, implements foo_c , uses not show warning.

number 1: works, no problem.

number 3: seems known bug/feature.. whatever..

there seems no explination #2 however. perhaps it's tied in #3, although nothing i've found makes mention of it.

anyone know if i'm missing here regarding regular virtual class member functions want deprecate?

btw: -wno-deprecate not turned on in makefiles.

given 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 version 4.1.2 20080704 (red hat 4.1.2-44)), same output describe:

g++     deprecate.cc   -o deprecate deprecate.cc: in function ‘int main()’: deprecate.cc:14: warning: ‘foo_b’ deprecated (declared @ deprecate.cc:3) 

but, on ubuntu 10.04.1 (gcc version 4.4.3 (ubuntu 4.4.3-4ubuntu5)), output expect:

g++     deprecate.cc   -o deprecate deprecate.cc: in function ‘int main()’: deprecate.cc:14: warning: ‘virtual void foo::foo_b()’ deprecated (declared @ deprecate.cc:3) deprecate.cc:16: warning: ‘virtual void foo::foo_b()’ deprecated (declared @ deprecate.cc:3) 

so, i'm guessing compiler bug got fixed.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -