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 28, 2023, at 5:53 PM, Roland Illig <roland.illig%gmx.de@localhost> wrote:
> 
> Am 15.03.2023 um 16:40 schrieb Jason Thorpe:
>> 
>>> 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.
> 
> I implemented this check as a lint warning, for both objects and functions.
> 
> Building NetBSD/amd64 results in 5054 new warnings, which makes this
> warning the second-most popular, right between the 11193 'conversion may
> lose accuracy' and the 4974 'argument unused in function'.

This is great, thanks Roland!  I suspected you would make this happen :-)

-- thorpej



Home | Main Index | Thread Index | Old Index