Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!spool.mu.edu!uwm.edu!lll-winken!unixhub!ditka!comeau From: comeau@ditka.Chicago.COM (Greg Comeau) Newsgroups: comp.std.c++ Subject: Re: Proposed: "closures" Keywords: proposal, closures, function pointers Message-ID: <38855@ditka.Chicago.COM> Date: 14 May 91 14:19:41 GMT Article-I.D.: ditka.38855 References: <1991Apr30.201532.13706@kestrel.edu> <1991May10.003304.12390@mathcs.sjsu.edu> <1991May12.194247.21483@news.cs.brandeis.edu> Sender: comeau@ditka.Chicago.COM (Greg Comeau) Reply-To: comeau@csanta.attmail.com (Greg Comeau) Distribution: comp.std.c++ Organization: Comeau Computing Lines: 40 In article <1991May12.194247.21483@news.cs.brandeis.edu> bs@chaos.cs.brandeis.edu (Benjamin Schreiber) writes: >In article <1991May10.003304.12390@mathcs.sjsu.edu> horstman@mathcs.sjsu.edu (Cay Horstmann) writes: >>Just out of curiosity: Suppose I have a variable f that holds a pointer >>to a "C" style void->void function and I want to make f local to its source >>file, do I say static extern "C" void (*f)(); No, that is a declaration with 2 storage class specifiers that differ in their linkage demands. >From reading the grammar, I get the feeling that the correct way to do this >is: extern "C" { static void (*f)(); }; It is. >Since any declarations/definitions are gramaticly allowed inside an extern >construct. The following may also be valid: extern "C" static void (*f)(); It is not. That still contained 2 storage class specifiers with different linkage. Getting back to the original data type though. This: extern "C" { static void (*f)(); }; is not "a variable f that holds a pointer to a "C" style void->void function". Instead it is f that is being extern C'd. The correct decl for the original problem would be: extern "C" typedef void (*ptCf)(); [static] ptCf f; This typedef ugliness must be used. I honestly don't know how many compilers accept this though. - Greg -- Comeau Computing, 91-34 120th Street, Richmond Hill, NY, 11418 Producers of Comeau C++ 2.1 Here:attmail.com!csanta!comeau / BIX:comeau / CIS:72331,3421 Voice:718-945-0009 / Fax:718-441-2310