MISRA Discussion Forums

Full Version: 19.7 no function-like macros
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi

Two questions about this rule:

1. Have somebody examples short for function-like macros?
2. When is a macro funktion-like?

best regards,
Manni
ISO defines a function-like macro to be a macro with a parenthesised argument list (which may be empty.)

For example, these are function-like macros

#define abs(x) (((x) >= 0) ? (x) : -(x))
#define pi() 3.14159265

MISRA-C Committee 27.4.2006