#pragma deprecate a function based on signature?
in Visual Studio is it possible to #deprecated a function, based on the signature of the function and not simply the name?
In my case we're in C++ and don't want to deprecate all flavors of the function
int foo(); <-- we want to keep
int foo(int 开发者_运维技巧x); <-- we want to deprecate
Just do this:
__declspec(deprecated) void foo(int) {}
And if you want the compiler to generate a specific message when compiling a deprecated function, then do this:
__declspec(deprecated("foo(int) is a deprecated function.")) void foo(int) {}
deprecated may also be specified in a __declspec()
, (which is even better than the #pragma
because it allows you to supply a reason if desired.
精彩评论