Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!ukma!uflorida!haven!mimsy!chris
From: chris@mimsy.UUCP (Chris Torek)
Newsgroups: comp.lang.c
Subject: Re: typedefs and prototypes
Message-ID: <13709@mimsy.UUCP>
Date: 23 Sep 88 15:23:20 GMT
References: <7135@bloom-beacon.MIT.EDU> <8543@smoke.ARPA> <13664@mimsy.UUCP> <12326@oberon.USC.EDU>
Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742
Lines: 48

In article <12326@oberon.USC.EDU> english@panarea.usc.edu (Joe English) writes:
>I found out by accident that such a construct does work in Borland's
>Turbo C (tm): ...

>typedef int func_t(int i, int j);
>
>func_t foo {
>  return i+j;
>}
>
>!!! Of course, func_t foo(int a, int b) is a "function returning a
>function," so the omission of the parameters in the definition makes
>'sense.'

True.  The dpANS says that the definition above (but, I think, NOT
the typedef declaration; for this I would have to check) is illegal.

>I just tried this construct on gcc, and it (quite rightly)
>doesn't work at all.

Incidentally, this has always bothered me about standard Pascal:

	type msgtype = array [1..80] of char; { or whatnot }
	procedure foo(i, j: integer; var msg: msgtype); forward;

	... many pages of code ...

	procedure foo;
	begin
	    { do stuff with i, j, and msg }
	end;
	...

One has to wonder where `i', `j', and `msg' came from:  Information
that is by rights purely local appears in a nonlocal place.

>Question: is giving parameter names in a
>function declaration (void foo(int i,int j);) part of the standard?

Yes.  The names themselves, however, are to be ignored by the compiler
(Turbo C is obviously not doing this).  (Whether this means that

	void foo(int i, char *i);

is legal I do not know.)
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris