Article View: net.lang.c++
Article #157Re: pointer to function argument bug
From: Tony L. Hansen
Date: Fri, 11 Apr 1986 03:30
Date: Fri, 11 Apr 1986 03:30
35 lines
1660 bytes
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
Technical Details
Message-ID:
<2761@pegasus.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!cbosgd!ihnp4!pegasus!hansenReferences:
<5275@alice.uUCp>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site pegasus.UUCP Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!cbosgd!ihnp4!pegasus!hansen From: hansen@pegasus.UUCP (Tony L. Hansen) Newsgroups: net.lang.c++ Subject: Re: pointer to function argument bug Message-ID: <2761@pegasus.UUCP> Date: Thu, 10-Apr-86 22:30:11 EST Article-I.D.: pegasus.2761 Posted: Thu Apr 10 22:30:11 1986 Date-Received: Sat, 19-Apr-86 03:32:57 EST References: <5275@alice.uUCp> Reply-To: hansen@pegasus.UUCP (60545457-Tony L. Hansen;LZ 3B-315;6243) Organization: AT&T-IS Labs, Lincroft, NJ Lines: 35 Keywords: function pointer Summary: how to get function pointers w/o typedefs