Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 2.1 deviation permit?
#1
Typically, on embedded systems with a simple RTOS, main is used as background task, so it never returns:

Code:
int main(void)
{
  Setup_Rtos();
  for (;;)
  {
    Background_Task();
  }
  return 0;// Violates MISRA C 2012 2.1: unreachable code
}

Would this be a candidate for your deviation permits document?
<t></t>
#2
Thank you for your suggestion for a deviation permit.
Posted by and on behalf of the MISRA C Working Group
#3
Technical Corrigendum 2 to MISRA C:2012 has added the following exception to rule 17.4.


Quote:For C99 and later, The Standard specifies that if control reaches the end of main without encountering a return statement, the effect is that of executing return 0. Therefore, for C99 and later, the return statement may be omitted for function main.
Omitting the return statement will remove the violation of rule 2.1
Posted by and on behalf of the MISRA C Working Group


Forum Jump:


Users browsing this thread: 3 Guest(s)