• Re: gcc and 'include'

    From Tim Rentsch@[email protected] to comp.lang.c on Sat Apr 25 10:09:31 2026
    From Newsgroup: comp.lang.c

    Keith Thompson <[email protected]> writes:

    Bart <[email protected]> writes:

    On 26/03/2026 23:12, Keith Thompson wrote:

    [...]

    (Unless you're using a C23 compiler, I suggest "int F(void)" rather
    than "int F()".)

    Nobody bothers with that any more.

    I presume that's meant to be hyperbole. Plenty of C programmers do
    bother with that.

    Most seem to assume that () already
    means zero parameters anyway, judging by the incorrect usage I
    constantly saw in open source code.

    I find it better to write correct code than to look for excuses
    to write poor code. If I define a parameterless function F, I
    absolutely want a diagnostic if I call it with one or more arguments.
    If nothing else, it's an opportunity to set a good example.

    The declaration "int F();" is correct code. Just because you
    don't like it doesn't mean it's wrong.
    --- Synchronet 3.21f-Linux NewsLink 1.2
  • From Keith Thompson@[email protected] to comp.lang.c on Sat Apr 25 15:58:38 2026
    From Newsgroup: comp.lang.c

    Tim Rentsch <[email protected]> writes:
    Keith Thompson <[email protected]> writes:
    Bart <[email protected]> writes:
    On 26/03/2026 23:12, Keith Thompson wrote:
    [...]

    (Unless you're using a C23 compiler, I suggest "int F(void)" rather
    than "int F()".)

    Nobody bothers with that any more.

    I presume that's meant to be hyperbole. Plenty of C programmers do
    bother with that.

    Most seem to assume that () already
    means zero parameters anyway, judging by the incorrect usage I
    constantly saw in open source code.

    I find it better to write correct code than to look for excuses
    to write poor code. If I define a parameterless function F, I
    absolutely want a diagnostic if I call it with one or more arguments.
    If nothing else, it's an opportunity to set a good example.

    The declaration "int F();" is correct code. Just because you
    don't like it doesn't mean it's wrong.

    You're right. I see that I unintentionally implied that it's wrong.
    I should have written "good code" rather than "correct code".

    "int F()" is correct code. For pre-C23 versions of C, it is in my
    opinion inferior to "int F(void)".

    I'm aware that you think "int F()" has some advantages in some
    circumstances.
    --
    Keith Thompson (The_Other_Keith) [email protected]
    void Void(void) { Void(); } /* The recursive call of the void */
    --- Synchronet 3.21f-Linux NewsLink 1.2