tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: style(5) proposal: forbid extern in .c



> On Mar 15, 2023, at 4:23 AM, Taylor R Campbell <campbell+netbsd-tech-userlevel%mumble.net@localhost> wrote:
> 
> Proposal: Forbid extern declarations in .c files.
> 
> extern declarations in .c files invite easily avoided bugs where the
> definition and use have mismatched types, because the compiler doesn't
> have an opportunity to check them.  Fix: Always put the extern
> declaration in a .h file shared by the .c file defining it and the .c
> files using it.
> 
> Pretty simple.  Any objections?

LGTM.  Would be nice if there was a way to get the compiler to enforce this.

-- thorpej



Home | Main Index | Thread Index | Old Index