Search code examples
c++c++11visual-studio-2012dependency-walker

Forbid linking against a c++ method


I try to forbid the use of a method, to have a compile error if some piece of code use it.

This is a proprietary legacy module, that I know that some methods are problematic. We have headers files, and dlls.

I can't figure out all the use of this method in the huge project I use (lot of defines, some implicit cast...)

Can the compiler stop (or just warn) if it detect the use of this method?


Solution

  • You can use __declspec(deprecated) in Visual C++ to generate warnings for use of a specific function. You can use #pragma deprecated to deprecate the usage of any symbol (including macros).

    See more information on MSDN. This can generate warnings or errors (depending on computer flags) but you can supress them where needed with additional #pragmas