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 12:55:13AM +0000, David Holland wrote:
> On Sat, Apr 15, 2023 at 11:47:08AM +0200, Roland Illig wrote:
>  > Since C90, function prototypes are available. They have become so common
>  > now that mentioning them is more confusing than helpful. I suggest
>  > removing these two lines:
>  > 
>  > >  * Use ANSI function declarations.  ANSI function braces look like
>  > >  * old-style (K&R) function braces.
>  > 
>  > I don't know what 'ANSI function braces' are or how they might differ
>  > from 'old-style function braces'. What is the point of this sentence,
>  > and why is it needed?
> 
> How about (given what people have said about the sentence):
> 
>   * Use full function prototypes in all declarations and definitions.
>   * The open-brace for a function body goes on its own line.
> 
> 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.

>  > 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.

Joerg


Home | Main Index | Thread Index | Old Index