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 Wed, Mar 15, 2023 at 11:23:05AM +0000, Taylor R Campbell 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?

Maybe an exception could be made for functions defined in an assembly file and
used from a single C file ?

-- 
Manuel Bouyer <bouyer%antioche.eu.org@localhost>
     NetBSD: 26 ans d'experience feront toujours la difference
--


Home | Main Index | Thread Index | Old Index