From: "G. Branden Robinson" <g.branden.robinson@gmail.com>
To: Alejandro Colomar <alx@kernel.org>
Cc: "Günther Noack" <gnoack3000@gmail.com>,
linux-man@vger.kernel.org, branden@debian.org,
"Jason Yundt" <jason@jasonyundt.email>
Subject: Re: [PATCH v1] CONTRIBUTING.d/style/c: Add coding style for the example programs
Date: Mon, 17 Feb 2025 16:35:37 -0600 [thread overview]
Message-ID: <20250217223537.rt4xhln6lip4kpaa@illithid> (raw)
In-Reply-To: <eawtdhfhbikpqnqygk6sisjb4drhzp6szneea2cajved6rwfkh@uf6ai7rjom4l>
[-- Attachment #1: Type: text/plain, Size: 1647 bytes --]
At 2025-02-17T23:16:59+0100, Alejandro Colomar wrote:
> On Mon, Feb 17, 2025 at 09:24:11PM +0100, Günther Noack wrote:
> > > +Name
> > > + style/c - C coding style
> >
> > "...for code examples in man pages"?
>
> I didn't specify, because it also applies to programs written in commit
> messages (for example to prove that a patch is correct). It applies to
> every C program that I have to look at as maintainer of this project
> (and actually, of any project that I comaintain too).
Maybe you need a name for this class/category.
"Colomar C coding style guide"?
> The definitions go all after main(). The prototypes go all before
> main(). The benefit is that you can get an overview of what is
> defined without having to look at the implementation.
My understanding is that function prototypes were added to the C
language to permit type-checking of function call arguments (and return
values) _across_ translation units--specifically. So if a function is
static, or has no callers outside of its translation unit,[1] the
compiler can be expected to exercise whatever type-checking facilities
it has within that translation unit. (I admit not knowing whether the
pre-ANSI Ritchie compiler or pcc were this careful. I'll brace myself.)
Regards,
Branden
[1] ...in which case the correct thing to do is _declare it static_, but
hey, this is C, man, we're "terse". More modern languages like Go
and Rust have started to recognize that having symbols be public
and/or mutable by default are worse choices for modularity and
concurrency. Even Ada was not quite this careful.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2025-02-17 22:35 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-08 22:44 [PATCH v1] CONTRIBUTING.d/style/c: Add coding style for the example programs Alejandro Colomar
2025-02-08 22:57 ` Alejandro Colomar
2025-02-08 23:46 ` G. Branden Robinson
2025-02-08 23:59 ` Alejandro Colomar
2025-02-09 0:45 ` G. Branden Robinson
2025-02-09 9:45 ` Alejandro Colomar
2025-02-09 2:20 ` onf
2025-02-17 20:24 ` Günther Noack
2025-02-17 22:16 ` Alejandro Colomar
2025-02-17 22:35 ` G. Branden Robinson [this message]
2025-02-17 23:03 ` Alejandro Colomar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250217223537.rt4xhln6lip4kpaa@illithid \
--to=g.branden.robinson@gmail.com \
--cc=alx@kernel.org \
--cc=branden@debian.org \
--cc=gnoack3000@gmail.com \
--cc=jason@jasonyundt.email \
--cc=linux-man@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox