tech-userlevel archive

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

Re: style: clean up mentions of old-style C



On Mon, Apr 17, 2023 at 03:06:53AM +0200, Joerg Sonnenberger wrote:
 > > The second point is an important part of the traditional layout, and I
 > > think the first is still worth stating. You _still_ see K&R-style
 > > code, 35-odd years notwithstanding.
 > 
 > I'd suggest to also explicitly call out that functions with no arguments
 > are written as f(void) in C.

+1

 > > > Declaring a prototype for 'main' is so uncommon that I don't see a point
 > > > mentioning it.
 > > 
 > > If it's going to be mentioned it should say "don't do that". It was a
 > > thing at one point, but a stupid thing...
 > 
 > There is actually a valid reason for having a prototype for main: it
 > makes it easier to rename main via macros and not run into certain
 > warnings.

...but if you're going to do that it seems like you should arrange for
a declaration of the new name to appear in a header somewhere in scope
(and in scope of the caller) and that those warnings shouldn't be
short-cut away.

Otherwise sooner or later you'll get bitten by a main() that expects
the env argument.

-- 
David A. Holland
dholland%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index