27-11-2021, 09:58 AM
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.
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