MISRA Discussion Forums
19.7 no function-like macros - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4)
+--- Forum: MISRA-C: 2004 rules (https://forum.misra.org.uk/forumdisplay.php?fid=17)
+---- Forum: 6.19 Preprocessing Directives (https://forum.misra.org.uk/forumdisplay.php?fid=43)
+---- Thread: 19.7 no function-like macros (/showthread.php?tid=247)



19.7 no function-like macros - Manni - 25-04-2006

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


- misra-c - 27-04-2006

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