🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Bjarne Stroustrup Wed, 09 Apr 1986 01:42
pointer to function argument bug
#151
Author: Bjarne Stroustrup
Date: Wed, 09 Apr 1986 01:42
20 lines
941 bytes
> 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 {}
Re: pointer to function argument bug
#157
Author: Tony L. Hansen
Date: Fri, 11 Apr 1986 03:30
35 lines
1660 bytes
< > 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
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