ANSI C function declaration prototypes

Doug Gwyn gwyn at smoke.BRL.MIL
Sat Jan 21 06:28:12 AEST 1989


In article <1776 at edison.GE.COM> rja at edison.GE.COM (rja) writes:
>1) How should I declare a function using prototypes when
>   that function has no parameters ??
>example:   int foo();

That means, in ANSI C, the same as in pre-ANSI C, namely, nothing
is specified about the (fixed) number or types of the arguments.

What you want in ANSI C is
	int foo(void);
Actually, the form you gave is 100% compatible with this, but it
does not allow the compiler to check for correct (empty) usage of
the arguments to the function.

>2) How should I declare a function which truly returns nothing ?

	void foo(/*whatever*/);

>   My first thought was to declare "void foo();" but that still
>   causes my compiler to warn about a function with no return value
>   when it compiles the function definition.

My guess is that the function definition neglects to specify "void"
return type.



More information about the Comp.lang.c mailing list