MISRA Discussion Forums
7-3-1 declarations and definitions - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C++ (https://forum.misra.org.uk/forumdisplay.php?fid=18)
+--- Forum: MISRA C++:2008 rules (https://forum.misra.org.uk/forumdisplay.php?fid=19)
+---- Forum: 6.7 Declarations (C++) (https://forum.misra.org.uk/forumdisplay.php?fid=136)
+---- Thread: 7-3-1 declarations and definitions (/showthread.php?tid=1102)



7-3-1 declarations and definitions - gs - 25-08-2014

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:
Code:
extern "C" void f();
void f() {}



Re: 7-3-1 declarations and definitions - misra cpp - 11-10-2016

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"