What is the advantage of using a macro in c?

As a question, What is the advantage of using a macro in c? What do you think is the advantage?

+3
source share
1 answer

Currently, I only use macros for very simple flags (conditional compilation, etc.).

The effectiveness of the built-in extension was taken using the keyword inline, constants can be improved with const, and lists of values ​​can be improved with enum.

These last two have the advantage that symbols are available to the debugger. With preprocessor values, they almost certainly turn into hard-coded values ​​before the compiler sees them. Constant variables and enumerations contain identifier information, which facilitates the debugging process.

+4
source

All Articles