[net.lang.c++] pointer to function argument bug

bs@alice.UucP (Bjarne Stroustrup) (04/09/86)

> From: cudcv@daisy.warwick.UUCP (Rob McMahon)
> 
> That reminds me - why do I have to say
> 
> typedef int (*PF)(int);
> int f ( PF f1 ) { ; }
> 
> when I mean
> 
> int f ( int (*f1)(int) ) { ; }
> 
> which says
> 
> "xx.c", line 1: error: syntax error

Because cfront suffers from a dumb YACC grammar. Try

int f ( auto int (*f1)(int) ) { }

PS You don't have the write { ; } when you mean {}

hansen@pegasus.UUCP (Tony L. Hansen) (04/11/86)

< > From: cudcv@daisy.warwick.UUCP (Rob McMahon)
< > ... why
< > typedef int (*PF)(int);
< > int f ( PF f1 ) { ; }
< > ... instead of
< > int f ( int (*f1)(int) ) { ; }
<
< From: alice!bs (Bjarne Stroustrup)
<
< Because cfront suffers from a dumb YACC grammar. Try
< 
< int f ( auto int (*f1)(int) ) { }

My copy of cfront accepts the above code, but then the generated code causes
/bin/cc to complain!

    "junk.c", line 2: illegal class

Passing this back to Bjarne gave this reply:

< ***> So it does! curse it. Sorry.  Re-reading my code, I find that 
<	I actually use
< 
<     	int f ( register int (*f1)(int) ) { }
< 
< 	but I think that I'll make the ``auto'' version work.
< 
< 	Could you possibly post a ``sorry, no AUTO, but REGISTER does
<	the trick'' note on the net?

There you have it. Use "register" instead of "auto" to get your pointers to
functions.

					Tony Hansen
					ihnp4!pegasus!hansen