MISRAC++2008-3-1-2
In this section:
Synopsis
(Required) Functions shall not be declared at block scope.
Enabled by default
Yes
Severity/Certainty
Medium/Medium

Full description
A function declaration was found at block scope. This check is identical to MISRAC2004-8.6, MISRAC++2023-6.0.1_a.
Coding standards
- MISRA C:2004 8.6
(Required) Functions shall be declared at file scope.
- MISRA C++ 2023 6.0.1
(Required) Block scope declarations shall not be visually ambiguous
Code examples
The following code example fails the check and will give a warning:
int foo() {
int bar();
return 0;
}
The following code example passes the check and will not give a warning about this issue:
int foo() {
return 0;
}
int bar();