Mail Archives: djgpp/1997/07/05/19:03:19
Chris Croughton wrote:
>
> There is a lot of code which does not need the return
> value of main ever, because main should never return.
> This includes all embedded software (mobile phones being
> the most ubiquitous example, since all phone software
> I've seen is written in C/C++).
Embedded software is a special case of C/C++ and may not have any
applicability to the general standard. How many times have you written
a program to run a mobile phone?
> The only case where
> there's likely to be unexpected action on the return code
> is if it's called from a makefile, and the code most
> people write is unlikely to be called like that (ever
> seen a game called from a makefile?). If a person is
> writing code for use with make or shell scripts which
> test the return value then it's up to them to make it
> return something sensible. However, just forcing a
> return of some kind doesn't make the value meaningful...
Sorry, but you're wrong. It is a generally recognized convention that
most programs should return a zero exit code to indicate that they ran
successfully. A non-zero exit code is usually some form of error
condition. Some programs obviously use the exit code for other things
(DOS 'choice' as an example). But I always write my programs using that
convention, on the assumption that somebody some day may decide to
examine the exit code to see what happened. This is called good
programming.
Lazy programmers, OTOH, will do anything they please, and nobody is
going to stop them. Just because their code might not _always_ work
doesn't mean they have to go to the incredibly strenuous effort of
typing a return statement. Nobody is going to tell them what they can
and can't do. Then they get hired by Microsoft... and look what
happens.
It's hardly worth the fuss you're making over it.
--
---------------------------------------------------------------------
| John M. Aldrich | "Sin lies only in hurting other |
| aka Fighteer I | people unnecessarily. All other |
| mailto:fighteer AT cs DOT com | 'sins' are invented nonsense." |
| http://www.cs.com/fighteer | - Lazarus Long |
---------------------------------------------------------------------
- Raw text -