Re: linux redirect problem




Flash Gordon wrote:
Bill Pursell wrote:
cmk128@xxxxxxxxxxx wrote:
Hi
here is my c file, compile in gcc 3.X in linux:

#include <stdio.h>

int main()
{
printf("Hello\n");
if (fork() == 0) printf("world! \n");
}

<snip>

2) Your program is invoking undefined behavior because
of an incorrect prototype for main.

No, it's a valid definition for main. Obsolescent possibly, but valid.

A few days ago, in a different thread, Richard Heathfield wrote:
Bill Pursell said:
Richard Heathfield wrote:
For each argv[n] where n >= 0 && n < argc, you can write to the
characters starting with argv[n][0] and going no further than the null
terminator.

Which is clear if you prototype main as int main(int argc, char
*const*argv),
plus you'll get a compiler warning if you try to write the values.

That's fine, provided your implementation documents that form for main().
Otherwise, ISTM that you are invoking undefined behaviour.

Is that consistent with what your saying? Is
int main()
merely obsolescent, or does it invoke undefined
behavior. If the former, is that consistent with Richard's
comment? I'm a little confused on this point.

.



Relevant Pages

  • Re: GCC difference in size of long int on Suse SLES9 / Suse Professional 10.0
    ... The kernel uses printf() with 'long int', ... I can't compile 'on-the-fly'. ... clashing with the hardware and any libs that you interact with. ... platform types build up their own int types. ...
    (comp.os.linux.development.apps)
  • Re: Im a C++ programmer, and Relfs X.CPP is good.
    ... >> and it doesn't compile either. ... home.cpp:93: implicit declaration of function `int fclose' ... You cannot change to your home directory through an external ...
    (comp.lang.lisp)
  • Re: Im a C++ programmer, and Relfs X.CPP is good.
    ... >> and it doesn't compile either. ... home.cpp:93: implicit declaration of function `int fclose' ... You cannot change to your home directory through an external ...
    (comp.unix.programmer)
  • Re: new order doubt
    ... Warning test2.c: 8 no type specified. ... Defaulting to int ... Tests probably come in several different types: this should compile ... Even Microsoft has problems with this obscure rules. ...
    (comp.lang.c)
  • Re: non-static context
    ... public MyStatic(int length, int width) { ... Within the MyStatic constructor method, a local variable named area is ... This version of class MyStatic won't compile. ...
    (comp.lang.java.help)