K&R-style variadic functions

Regan Heath regan at netmail.co.nz
Wed Jul 18 03:23:33 PDT 2012


On Tue, 17 Jul 2012 19:39:25 +0100, H. S. Teoh <hsteoh at quickfur.ath.cx>  
wrote:

> On Tue, Jul 17, 2012 at 08:07:08PM +0200, Paulo Pinto wrote:
>> On Tuesday, 17 July 2012 at 15:16:56 UTC, Regan Heath wrote:
> [...]
>> >So all K&R function declarations were <name>() with no parameters.
>> >
>> >R
>>
>> K&R was more than that.
>
> This modern C declaration:
>
> 	int main(int argc, char **argv) {
> 		exit(1);
> 	}
>
> is written thus in K&R:
>
> 	int main(argc, argv)
> 		int argc;
> 		char **argv;
> 	{
> 		exit(1);
> 	}

Clarification.

The /definition/ is as you have above, the /declaration/ is not.  The  
declaration is what goes in the header file, and in K&R (and ANSI C for  
that matter) looks like:

int main();

parameters are not required for the declaration, only the definition.

R

-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/


More information about the Digitalmars-d mailing list