Re: linux redirect problem
- From: "Bill Pursell" <bill.pursell@xxxxxxxxx>
- Date: 28 Jun 2006 12:06:46 -0700
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.
.
- Follow-Ups:
- Re: linux redirect problem
- From: Richard Heathfield
- Re: linux redirect problem
- References:
- linux redirect problem
- From: cmk128
- Re: linux redirect problem
- From: Bill Pursell
- Re: linux redirect problem
- From: Flash Gordon
- linux redirect problem
- Prev by Date: Re: qsort() results: implementation dependent?
- Next by Date: Re: Working with negative numbers
- Previous by thread: Re: linux redirect problem
- Next by thread: Re: linux redirect problem
- Index(es):
Relevant Pages
|