简体   繁体   中英

Code that won't compile in C, C++ and Obj-C with a specific error message

I'm replacing one C-style macro with another.

#define OldMacro(…) {…}

#define NewMacro(…) {…}

I'd like to rewrite the old version of the macro so that it fails to compile with a specific error message, ie something like: "OldMacro() is deprecated; use NewMacro() instead." Is this possible?

Also, I'd like this to work in C, C++ and Objective-C.

您可以使用此宏定义:

#define OLD_MACRO()  (error_use_of_OLD_MACRO_is_deprecated = 0)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM