Macro Routines and Inline Routines
Routines created with preprocessor macros call for a few unique considerations. The following rules and examples pertain to using the preprocessor in C++. If you're using a different language or preprocessor, adapt the rules to your situation.
Cross-Reference
Even if your language doesn't have a macro preprocessor, you can build your own. For details, see Building Your Own Programming Tools.
Fully parenthesize macro expressions. Because macros and their arguments are expanded into code, be careful that they expand the way you want them to. One common problem lies in creating a macro like this one:
Example 7-10. C++ Example of a Macro That Doesn't Expand Properly
#define Cube( a ) a*a*a
If you pass this macro nonatomic ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access