3.2 Program and linkage

3.2.1 Do not declare functions at block scope

A declaration for a function should be common to its definition, any redeclarations, and any calls to it. To ensure that the same type is used in all declarations, functions should always be declared at namespace scope (See Rules <hicpp ref=”dcl.link.single-decl”/> and <hicpp ref=”dcl.link.unnamed-ns-members”/>).

#include <cstdint>
int32_t bar ()
int32_t foo ();    // @@- Non-Compliant -@@
return foo ();
int32_t foo ()


  • JSF AV C++ Rev C – 107
  • MISRA C++:2008 – 3-1-2

Click here for references