总共分三步:
1.在发布dll库的头文件中,把API声明如下:
#define MY_TXT "function MyApi is not safe, consider using MyApiEx instead."
__declspec(deprecated(MY_TXT)) EXPORT void MyApi();
2.当用户调用该API时,编译时给出警告,如下:
1>xxxx.cpp
1>xxxx.cpp:warning C4996: 'MyApi':function MyApi is not safe, consider using MyApiEx instead.
1> xxxxx.h: 参见xxx的声明
3.不调用不会产生警告,这种方式比“#pragma message("warning: xxxx")”方法可控;