19.7 no function-like macros

6.19 Preprocessing Directives

Moderators: misra-c, david ward

Locked
Manni
Posts: 11
Joined: Mon Feb 20, 2006 12:28 pm

19.7 no function-like macros

Post by Manni » Tue Apr 25, 2006 9:58 am

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
best regards,
Manni

misra-c
Posts: 572
Joined: Thu Jan 05, 2006 1:11 pm

Post by misra-c » Thu Apr 27, 2006 10:24 am

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
---
Posted by and on behalf of
the MISRA C Working Group

Locked

Return to “6.19 Preprocessing Directives”