Before I start, IANACH (I Am Not A Compiler Hacker), so don't blame me
if my code is horrible.
Something I've noticed in large code bases (e.g. FreeBSD), is that even
though people use compiler flags like -Wmissing-prototypes and fix their
code accordingly, the same type of problem exists for global variables.
This could in theory cause certain optimisations to be missed, but it
also causes namespace issues.
So my idea would be to have a compiler flag that would cause Clang to
generate a warning for this. So for example:
static int i;
extern int j;
Attached is a patch that adds a new warning flag called
-Wmissing-variable-declaration that implements this behaviour. Any
missing-variable-declaration.diff (1.59 KB)