views:

213

answers:

3

Is there a way of marking methods/classes in C++ as obselete as I would to in c# as follows:

[Obsolete("You shouldn't use this method anymore.")] void foo(){}

I use the GNU toolchain/Eclipse CDT if that matters.

+6  A: 

Only using compiler dependent pragmas: look up the documentation

 int old_fn () __attribute__ ((deprecated));
dirkgently
A: 

I don't know about the version of C++ you are using, but Microsoft's Visual C++ has a deprecated pragma. Perhaps your version has something similar.

Matt Davis
+3  A: 

The easiest way is with a #define DEPRECATED. On GCC, it expands to __attribute__((deprecated)), on Visual C++ it expands to __declspec(deprecated), and on compilers that do not have something silimar it expands to nothing.

MSalters