Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rules 21.1 and 21.2. Possible contradiction with rule 11.9 and directive 4.6.
#2
Question 1.
Rule 11.9 permits both the use of "(void*)0" or the use of a macro that expands to "(void*)0".
The examples in the MISRA C:2012 guidelines includes the compliant use of
Code:
#define MY_NULL_2 (void*)0

Question 2.
The amplification of rule 21.1 ( which is also applied to rule 21.2 ) refers to "identifiers in file scope described in Section 7, "Library", of The Standard". There is no mention of linkage and therefore "reserved identifiers" also covers typedef names declared in stdint.h.

Ideally for C99 the types provided by stdint.h should be used. The project plan should otherwise provide documentation as to why this aspect of directive 4.6 is not followed.
The other aspects of directive 4.6 can be followed by using typedefs which do not clash with names in stdint.h. This avoids a violation of rule 21.1. For example:
Code:
typedef int INT32;

Question 3.
Yes, the prohibition also applies to rule 21.2. The whole of the amplification for 21.1 applies to 21.2.
The rule applies even if the standard header file is not included. Confusion might arise if reviewers or later developers make an incorrect assumption that the behaviour of the declaration behaves in the same way as that of the standard library.

Rule 21.2 may be deviated if the project can guarantee that the behaviour is the same as that of the standard library. The evidence for a deviation to rule 21.2 should be recorded in a //deviation record//. You are advised to read the MISRA Compliance document which can be found at https://tinyurl.com/MisraCompliance [^] which gives advice on writing //deviation records//.
Posted by and on behalf of the MISRA C Working Group
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)