5

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 

2 Answers 2

12

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) {} 
Sign up to request clarification or add additional context in comments.

1 Comment

Beat me by some 40 seconds. Damn you! +1 :)
3

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.