Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 17.4 and main
The MISRA C:2012 guidelines do not require an "int" return type from "main". The documentation for directive 1.1 states that main is commonly declared as "void main (void )" in freestanding implementations.

Therefore it is permissable to declare main to have a void return type. Your compiler may be configurable to permit a void return or the compiler warning noted, but ignored. For example, the clang compiler warning can be suppressed by using  -Wno-main-return-type

However, it is appreciated that not all compilers may have this option and the MISRA Working Group are likely to add an exception to rule 17.4 which will permit the use of  "main" with no return statement in the next Technical Corrigendum.
Posted by and on behalf of the MISRA C Working Group

Messages In This Thread
Rule 17.4 and main - by hummelvario - 01-10-2021, 09:59 AM
RE: Rule 17.4 and main - by misra-c - 27-11-2021, 09:58 AM

Forum Jump:

Users browsing this thread: 1 Guest(s)