🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Pierre DAVID Wed, 14 Sep 1988 15:46
typedef-name as a parameter name
#5359
Author: Pierre DAVID
Date: Wed, 14 Sep 1988 15:46
37 lines
1163 bytes
Hello C gurus !

I would like to know if these two programs are ANSI-C strictly conforming
or not.  If not, I would appreciate if someone could tell me exactly
why (I have the January 1988 draft).


----- Program A -------------------------
typedef int t1, t2 ;

void f1 (t1) ;	    /* "t1" is the parameter type */

void f2 (t2)	    /* "t2" is a parameter, hiding "t2" type definition */
int t2 ;
{
    void f3 (t1) ;  /* "f3" declaration. "t1" is the type of the parameter */
}

----- Program B -------------------------
typedef int type ;

/*
 * "f" is of type "type"
 * "f" has a parameter named "type" whose type is "type"
 */
type f (type type)
{
    return type+1 ;
}
-----------------------------------------

Thanks to all.

Pierre David
pda@litp.uucp
...!uunet!mcvax!inria!litp!pda
Re: typedef-name as a parameter name
#5360
Author: Pierre DAVID
Date: Thu, 15 Sep 1988 13:48
35 lines
1099 bytes
In article <387@litp.UUCP>, I wrote:

> I would like to know if these two programs are ANSI-C strictly conforming
> or not.  If not, I would appreciate if someone could tell me exactly
> why (I have the January 1988 draft).
> 
> typedef int t1, t2 ;
> void f1 (t1) ;
> void f2 (t2)
> int t2 ;
> {
>     void f3 (t1) ;
> }
>
> typedef int type ;
> type f (type type)
> {
>     return type+1 ;
> }


The answer is NO !

I have found the answer in paragraph 3.7.1 (Function definitions), in
"Constraints" :

	An identifier declared as a typedef name shall not be
	redeclared as a parameter.

One more C particularism...


Pierre David
pda@litp.uucp
...!uunet!mcvax!inria!litp!pda
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads