开发者

#pragma deprecate a function based on signature?

开发者 https://www.devze.com 2023-02-07 06:26 出处:网络
in Visual Studio is it possible to #deprecated a function, based on the signature of the function and not simply the name?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消