开发者

What's the advantage of using macro in c? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. 开发者_开发问答 Closed 11 years ago.

Just as the question, What's the advantage of using macro in c? What do you think is the advantage?


Nowadays, I only use macros for very simple flags (conditional compilation and such).

The efficiency of inline expansion has been taken up by the inline keyword, constants can be done better with const, and lists of values can be done better with enum.

Those latter two have the advantage that the symbols are available to the debugger. With preprocessor values, these almost certainly turn into hard-coded values before the compiler proper sees them. Constant variables and enumerations keep the identifier information available, making the debug process a lot easier.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜