int main() and rule 6.3

6.6 Types

Moderators: misra-c, david ward

Posts: 70
Joined: Mon Dec 10, 2007 1:57 pm

int main() and rule 6.3

Post by Lundin » Mon Jun 23, 2008 2:23 pm

I was wondering whether rule 6.3 applies to int main() or if this is should be a special exception? Ie should we write sint16_t main() or not?
Because if we state the width and signedness of main() we will suddenly make the app implementation-dependant and non-portable.

Also, ISO C strictly states that the return type shall be "int" on a hosted environment. One could interpret that as "it must be the primitive
data type int and no custom typedef".

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

Re: int main() and rule 6.3

Post by misra-c » Wed Sep 24, 2008 9:25 am

In the definition of main, use the basic types int and char rather than fixed length typedefs.

This will be included in a future revision of MISRA C.
Posted by and on behalf of
the MISRA C Working Group


Return to “6.6 Types”