[prev in list] [next in list] [prev in thread] [next in thread] 

List:       netbsd-tech-userlevel
Subject:    Re: style(5) proposal: forbid extern in .c
From:       Jason Thorpe <thorpej () me ! com>
Date:       2023-03-28 15:01:02
Message-ID: EBC5AED3-2EE5-47DA-8987-2AC9412CF2C9 () me ! com
[Download RAW message or body]



> On Mar 28, 2023, at 5:53 PM, Roland Illig <roland.illig@gmx.de> 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> 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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic