【发布时间】:2011-01-27 17:58:11
【问题描述】:
在 Visual Studio 中,是否可以根据函数的签名而不是简单的名称来#deprecated 函数?
在我的例子中,我们使用 C++ 并且不想弃用该函数的所有风格
int foo(); <-- we want to keep
int foo(int x); <-- we want to deprecate
【问题讨论】:
标签: c++ visual-c++ deprecated
在 Visual Studio 中,是否可以根据函数的签名而不是简单的名称来#deprecated 函数?
在我的例子中,我们使用 C++ 并且不想弃用该函数的所有风格
int foo(); <-- we want to keep
int foo(int x); <-- we want to deprecate
【问题讨论】:
标签: c++ visual-c++ deprecated
这样做:
__declspec(deprecated) void foo(int) {}
如果您希望编译器在编译已弃用的函数时生成特定消息,请执行以下操作:
__declspec(deprecated("foo(int) is a deprecated function.")) void foo(int) {}
【讨论】:
deprecated may also be specified in a __declspec(),(这甚至比#pragma 更好,因为它允许您在需要时提供原因。
【讨论】: