Re: Doubt
- From: santosh <santosh.k83@xxxxxxxxx>
- Date: Thu, 31 Jul 2008 16:26:57 +0530
Anarki wrote:
int main(a,b,c,d,e,f,g)
You are using the so-called "old style" function definition without a
declaration list specifying the types of the parameters. In such a case
they default to type int.
Further note that unless your implementation specifically defines this
form of main, (i.e., int main(int, int, int, int, int, int, int)), you
are invoking undefined behaviour.
{
printf("Size of a = %d\nSize of b =%d",sizeof(a),sizeof(b));
The sizeof operator yields a value of type size_t. The 'd' type
specifier is for int values. Use 'z' if available, or 'lu' and cast to
unsigned long.
return 0;
}
The above program perfectly compiles in cygwin using gcc
and my questions are
1.How does the compiler know what are the types of variables a, b, c,
d, e, f and g?? Where is its declaration?
As above.
2.I haven't included stdio.h yet the printf compiles.The compiler
doesn't complain about the requirement of function prototype, why?
If you had invoked your compiler in conforming mode then it would have.
For gcc use the -ansi/-std=c99 and -pedantic flags for C90 or C99
conformance. C99 conformance is incomplete.
.
- Follow-Ups:
- Re: Doubt
- From: Richard Heathfield
- Re: Doubt
- References:
- Doubt
- From: Anarki
- Doubt
- Prev by Date: Re: Doubt
- Next by Date: Re: Doubt
- Previous by thread: Re: Doubt
- Next by thread: Re: Doubt
- Index(es):
Relevant Pages
|