When defining macro with zero arguments we can define it with parentheses, thus looking more like function开发者_StackOverflow社区 or without parentheses.
What is preferable (probably there's no right answer) way of doing it?
As a general rule, I would expect MACRO()
to generate executable code, which may have side-effects. I use MACRO
(sans parentheses) for more structural things that yield declarations, boilerplate, or constants.
If you intend to create a macro that mimics a function, then use the ()
version. Otherwise don't.
Yes, we can and I don't think that there's really any particular technical reason why one is better than the other. However, conventionally we would omit the ()
where not required.
精彩评论