MISRA 20.2

6.20 Standard Libraries

Moderators: misra-c, david ward

ankitshah413
Posts: 14
Joined: Wed Feb 14, 2018 10:02 am
Company: Inform GmbH

MISRA 20.2

Postby ankitshah413 » Thu Apr 26, 2018 3:18 pm

Hello,

Why the following code is the violation of MISRA 20.2 ?

Code: Select all

#define abs(a)   (((a) < (0)) ? -(a) : (a))


As far as I understand from the topics , 20.2 does not concern with preprocessor identifier then why I get an violation for the same.

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

Re: MISRA 20.2

Postby misra-c » Fri May 04, 2018 12:43 pm

Rule 20.2 refers to the declaration of non-preprocessor names. i.e. objects, function names, typedefs. This code is not a violation of rule 20.2, but does violate rule 20.1 which does not permit standard library functions to be used in a #define.
---
Posted by and on behalf of
the MISRA C Working Group


Return to “6.20 Standard Libraries”

Who is online

Users browsing this forum: No registered users and 2 guests