Deutsch   English   Français   Italiano  
<v4pe9e$lpi6$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!news.nobody.at!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: James Kuyper <jameskuyper@alumni.caltech.edu>
Newsgroups: comp.lang.c
Subject: Re: Whaddaya think?
Date: Mon, 17 Jun 2024 09:38:54 -0400
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <v4pe9e$lpi6$1@dont-email.me>
References: <666ded36$0$958$882e4bbb@reader.netnews.com>
 <20240616015649.000051a0@yahoo.com> <v4lm16$3s87h$4@dont-email.me>
 <v4lmso$3sl7n$1@dont-email.me> <v4lr0m$3tbpj$1@dont-email.me>
 <8734pd4g3s.fsf@nosuchdomain.example.com> <v4ltuj$3trj2$1@dont-email.me>
 <87y17530a0.fsf@nosuchdomain.example.com> <v4mb92$3ak$1@dont-email.me>
 <87tths39yy.fsf@nosuchdomain.example.com> <v4oi9f$gnf3$1@dont-email.me>
 <877ceo2iqq.fsf@nosuchdomain.example.com> <v4onrg$hmc2$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 17 Jun 2024 15:38:55 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="a7b132bb65603ea19d45fd3964c95a9e";
	logging-data="714310"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/1m6nN3S3PH/VJEHdWPPP82jP7rJv6BhQ="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:hy1Y8GUtBjsqFxeNW5wQvB3NtOg=
Content-Language: en-US
In-Reply-To: <v4onrg$hmc2$1@dont-email.me>
Bytes: 3809

On 6/17/24 03:16, Janis Papanagnou wrote:
> On 17.06.2024 08:20, Keith Thompson wrote:
>> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
....
>> and
>> that's important to understand.  It's effectively called by the
>> environment, which means that your definition has to cooperate
>> with what the environment expects. 
> 
> I'm not sure whether my K&R copy addresses that at all. A quick
> view and I see only one instance where "main()" is mentioned at
> the beginning:   main() { printf("hello, world\n"); }
> No types here, and no environment aspects mentioned.

K&R C did not have function prototypes. main() declared with no
arguments indicates that main takes an unknown number of arguments, of
unspecified type - as such it's compatible with taking either two
arguments, or none. For backwards compatibility, you're still allowed to
declare functions K&R style, but it's been more than 3 decades since it
was a good idea to do so.

....
>>> If I want a defined exit status (which is what I usually
>>> want) I specify 'int main (...)' and provide an explicit
>>> return statement (or exit() call).
>>
>> Why would you ever not want a defined exit status, given that it's
>> easier to have one than not to have one? 
> 
> Aren't we agreeing here? (The only difference is that you are
> formulating in a negated form where I positively said the same.)

You implied, by saying "If I want a defined exit status", that there are
occasions where you don't want a defined exit status - and he's
questioning that. Things that are undefined are seldom useful. If the
exit status is undefined, it might be a failure status. In many
contexts, that would cause no problems, but there's also places where it
would.

....
> Well, to indicate that there's no status information or that
> it's irrelevant. E.g. as was the case in the test fragment I
> posted.

That's the problem - your "indication that there's no status
information" doesn't achieve the desired effect. Instead, it results in
an unspecified status being returned to the system. If might be a
successful status, or an unsuccessful status. On the systems I use,
scripts that execute programs will often abort if the program returns an
unsuccessful status code. If there's nothing that needs to be brought to
the system's attention, use "return 0;", not "void main()".