Sujet : Re: Baby X is bor nagain
De : bc (at) *nospam* freeuk.com (bart)
Groupes : comp.lang.cDate : 29. Jun 2024, 21:55:54
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v5posa$2kq0$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
User-Agent : Mozilla Thunderbird
On 29/06/2024 18:46, Richard Harnden wrote:
On 29/06/2024 15:14, bart wrote:
[...]
My older bcc compiler reported 4 as a hard error unless an override was used.
But you didn't say anything about main's args.
I did, indirectly. The actual error was the use of "()" as an empty parameter list (for any function, not just main, but my example could also have been 'void H(){H(123);}'). If you tried to compile:
int main() {
main(123);
}
then it wouldn't get past the () to the call.
Eventually I dropped that restriction, and the reason was that so much code used such parameter lists, for any function.
Not because they wanted unchecked args (there are some legitimate use-cases within function pointer types), but because so many people assumed () meant zero parameters like (void).
Why was such code so common? Presumably because compilers said nothing; and they couldn't because the language allowed it. If they had required an override like mine did, more would have got the message.
Now it's too late because apparently the meaning of () is changing to mean (void). All those people who got it wrong (and introduced a dangerous bug) have won!