Path: utzoo!attcan!uunet!aplcen!samsung!cs.utexas.edu!milano!czech!krohn From: krohn@czech.sw.mcc.com (Eric Krohn) Newsgroups: comp.lang.c++ Subject: Re: function variable Message-ID: <3988@czech.sw.mcc.com> Date: 20 Jul 90 16:36:30 GMT References: <10983@paperboy.OSF.ORG> Reply-To: krohn@czech.sw.mcc.com (Eric Krohn) Organization: MCC, Austin, Texas Lines: 29 In article <10983@paperboy.OSF.ORG> daniel@osf.org (Daniel Dardailler) writes: ] I have a g++ problem: ] ] main() ] { ] int (* foo) (); ] } ] doesn't compile with: `foo' undeclared (first use this function) Welcome to one of the C++ language's inherent ambiguities. A statement of the form T (* foo) (); (where T is a typename) could be either: 1) an expression // Dereference foo, cast it to a T, call function or // overloaded operator (). 2) a declaration // foo is pointer to function returning T. As of AT&T's C++ 2.0, the language manual says if a statement can be parsed as either an expression or a declaration, then it must be parsed as a declaration. In your case, g++ parsed it (incorrectly) as an expression. When you added the storage class specifier (static), you disambiguated the statement so that it could only be parsed as a declaration. If you want to force your statement to be parsed as an expression, you can say 0, int (*foo) (); -- Eric J. Krohn krohn@sw.mcc.com