If C is so evil why is it so successful?

Sean Conner spc at conman.org
Wed Apr 12 13:43:14 CDT 2017


It was thus said that the Great Alfred M. Szmidt once stated:
>    It was thus said that the Great Noel Chiappa via cctalk once stated:
>    >     > From: Alfred M. Szmidt
>    > 
>    >     > No even the following program:
>    >     >   int main (void) { return 0; }
>    >     > is guaranteed to work
>    > 
>    > I'm missing something: why not?
> 
>      Yeah, I'm having a hard time with that too.  I mean, pedantically, it
>    should be:
> 
> 
>          #include <stdlib.h>
>          int main(void) { return EXIT_SUCCESS; }
> 
> Pedantically, it does not matter -- a return from main is equivalent
> to an exit(), and exit(0) is sensibly defined, and EXIT_SUCCESS can
> also be different from 0 (even though I don't think such a platform
> exists).
> 
> Similiarly for EXIT_FAILURE ...

  There's this
(http://stackoverflow.com/questions/8867871/should-i-return-exit-success-or-0-from-main/8868139#8868139):

        Somebody asked about OpenVMS. I haven't used it in a long time, but
        as I recall odd status values generally denote success while even
        values denote failure. The C implementation maps 0 to 1, so that
        return 0; indicates successful termination. Other values are passed
        unchanged, so return 1; also indicates successful termination.
        EXIT_FAILURE would have a non-zero even value.

  And certainly VMS is on topic for this list.

  -spc (So ... pedantically speaking, who's correct?)



More information about the cctalk mailing list