On Dec 15, 2007 2:50 AM, John W. Krahn <[EMAIL PROTECTED]> wrote:
snip
> > $ cat test.c
> > #include <stdio.h>
> >
> > main () {
>
> In C the main function returns an int so that is not compliant with the
> C standard[3].  It should be:
>
> int main ( void ) {
>
> >     printf("hello world");
snip

That depends on the version of C you are using.  Given the lack of
other syntax in this short program I cannot tell if it is K&R C, ANSI
C, or C99.  If he is using K&R C, that is a perfectly fine main
definition (int return type is assumed for functions that don't
specify).  The whole putting a void in the argument list thing came
from C++; it is still perfectly valid (from K&R to C99) to define your
main like this

int main () {

snip
> I think that anyone with an idea in their head can make a case for any
> absurd notion but that does not make it right or standards compliant.
snip

I agree with this whole heartedly.  All versions of C are loaded guns.
 Anyone can pick one up, but that doesn't mean I want to stand next to
that person.  But I think Jeff's main point was, since it is possible,
how should we handle it?  My suggestion is to do physical harm to the
person if you can find him or her until he or she agrees to stop being
an idiot.  If you can't find the person responsible for it, then avoid
the software (because if it gets this fundamental thing wrong, what
else is wrong with it).  And as a last case (you can't find the person
and you have to use the software), write a wrapper script* that
corrects this issue and document the heck out of the line where you do
the system** call.

* something like this (warning untested)
#!/bin/sh

/path/to/broken/prog/i_am_borked
rc=$?
case $rc in
    0) exit 1;;
    1) exit 0;;
    *) exit $rc;;
esac

** Doing a system call at all is a red flag.  It is rarely needed
unless you are using Perl to puppet string** another process, and even
then IPC::Open3 is often a better tool.
*** that is the purpose of your script is to take the place of a human
interacting with the system

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to