Whether predefined macros in CPP should be replaced by inline functions

in < Effective CPP >, there is a clause like this:
Modern CPP programming principles do not recommend the application of macro definition constants or function macros. You should use-sharpdefine as little as possible and, if possible, use const variables or inline functions instead.

but in the Debug program, you need some predefined macros, such as _ _ DATE__,__FILE__,__LINE__,__FUNCTION__, etc. In the face of this situation, should inline be used instead of define?

how to replace the following if needed.

-sharpdefine log_err(M, ...) fprintf(stderr, "[ERROR] (%s:%d: errno: %s) " M "\n", __FILE__, __LINE__, clean_errno(), -sharp-sharp__VA_ARGS__)
C cPP
Mar.23,2021

I think the greatest value of using define is whether it is possible to condense large chunks of repetitive code into define, for subsequent use, possibly using a macro to solve large chunks of repetitive code. For example, message mapping in mfc successfully condenses a lot of repetitive code into one or two macros. Although mfc itself is complex, the use of its macro definition can be regarded as a textbook. Other common usage scenarios, such as defining functions of variable length, are the examples you give. For example, related to the operating system and compilation environment, such as _ _ FILE__,__LINE__,DEBUG and so on. As for the possible substitution you are talking about, I think it is to define constants, simply defined functions, and so on.


the meaning above is right. For replaceable macro definitions, such as defined macro constants, or macro functions, try to use const or inline


.

sometimes macros have special uses.

/*Adapted from HttpParser*/
-sharpdefine XX(meth, str) \
case (char == HTTP_-sharp-sharpmeth): \
    http_parser->method = HTTP_-sharp-sharpmeth;

...
-sharpundef XX

this makes it impossible to replace

with inline.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b40721-2c540.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b40721-2c540.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?