Function declaration issues

Andrew Pinski pinskia@physics.uc.edu
Thu Sep 4 14:51:00 GMT 2003


Because in C, a function declared as () means any number of arguments,
this goes back to K&R C.

Thanks,
Andrew Pinski


On Wednesday, September 3, 2003, at 07:01 PM, Nikita Shulga wrote:

> Hi all!
>
> I was trying to understand, what's the difference between function 
> declaration and prototype. I write the following very simple program, 
> and I wander, if it is all right, to compile without any warnings(of 
> course, with -Wall option)
> gcc version is 3.2.1.
> Here goes the code:
> /*-----------------------------------------------------------*/
> #include <stdio.h>
> int a();
> int main(void) {
>         a("String", 3.1417);
>         a(1, NULL);
>         return a();
> }
> int a(int c, int d) {
>         printf ("c=%d, d=%d\n", c, d);
>         return c+d;
> }
> /*----------------------------------------------------------*/
> And why I can call to a() with any agrument's I like?
> Thanks in advance,
> 	Nikita
>
>



More information about the Gcc mailing list