Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Meaning of rule 8.4 for function prototypes
#1
Consider the following:

File1.h:
typedef short int int16_t;

File2.h:
short int foo(short int a);

File3.h:
int16_t foo(int16_t a);

Does this break any MISRA rules? I ask because rule 8.3 states that for a function, the types in the prototype must match the types in the definition *exactly*. However, rule 8.4 states that when an object *or function* is declared more than once, the types in the declarations must be compatible, which is a weaker requirement. Why were the words "or function" included in rule 8.4?

My intepretation is that if my source code includes a definition of function foo, then I must be violating rules 8.3 (because at most one of the prototypes can have types that exactly match the types in the definition); but it my code doesn't include a definition for foo (e.g. because it is in a compiler-supplied library), I am free to provide two or more prototypes for it with non-identical but compatible types.
<r>David Crocker<br/>
Escher Technologies Ltd.<br/>
<URL url="http://www.eschertech.com">http://www.eschertech.com</URL></r>
Reply
#2
This was not intentional and it will be corrected in the next version of MISRA C.
Posted by and on behalf of the MISRA C Working Group
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)