MISRA Discussion Forums

Full Version: 7-3-1 declarations and definitions
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Does rule 7-3-1 require a function declared at global scope be declared as "extern 'C'" for both the function's declaration and its definition or does one "extern 'C'" for that function suffice? For example, is this okay:
extern "C" void f();
void f() {}
What you're written is compliant, but not what the rule intended. The intent of the rule was that no functions would be declared at global scope, other than main or those imported from C libraries using extern "C"