[cfe-commits] [Patch] Add -Wmissing-variable-declarations

Ed Schouten ed at 80386.nl
Fri Dec 9 14:24:42 PST 2011


Hi folks,

Attached is a patch to add a new type of compiler warning to Clang,
namely -Wmissing-variable-declarations.

Basically it acts like -Wmissing-prototypes, but then for global
variables. This warning forces people to properly mark global variables
as static or properly add an extern declaration.

I have already used this patch to make various changes to the FreeBSD
kernel and utilities. My observation is that marking stuff static tends
to reduce the binary size, but it even allows the compiler to place more
stuff in read-only segments if the user forgets to mark globals const.

Best regards,
-- 
 Ed Schouten <ed at 80386.nl>
 WWW: http://80386.nl/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: missing-variable-declarations.diff
Type: text/x-diff
Size: 2059 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20111209/e898df8a/attachment.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 834 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20111209/e898df8a/attachment.sig>


More information about the cfe-commits mailing list