Don't use function macros; they are problematic. Instead, declare the functions inline to obviate the need for function macros (see "Inline functions" on page 90 for restrictions). Like
const, inline functions follow the C++ scope rules and allow argument type-checking. Both member functions and nonmember functions can be declared inline. Consider this classic example:
When written as an inline, it is actually more efficient than the macro version. What's more, it's correct.
#define SQUARE(x) ((x)*(x))
SQUARE(y++); // y incremented twice
inline int Square(int x)
Square(y++); // y incremented once
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.
Generated with WebMaker