Xref: utzoo comp.lang.c++:6854 gnu.g++:714 gnu.g++.bug:1598 Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!rutgers!usc!ucsd!helios.ee.lbl.gov!pasteur!katerina.berkeley.edu!c164-cz From: c164-cz@katerina.berkeley.edu (Andrew Choi) Newsgroups: comp.lang.c++,gnu.g++,gnu.g++.bug Subject: Problem with declaring pointer to function Message-ID: <23181@pasteur.Berkeley.EDU> Date: 17 Mar 90 22:30:22 GMT Sender: news@pasteur.Berkeley.EDU Reply-To: c164-cz@katerina.berkeley.edu (Andrew Choi) Distribution: usa Organization: University of California, Berkeley Lines: 49 I discovered a bug (or is it?) while trying to compile the following simple program: void print(void) { ; /* dummy statement */ } int main(void) { void (*funcPointer)(void); // This is line 9 funcPointer = print; funcPointer(); (*funcPointer)(); return 0; } Here is the message the compiler gave me: bug.C: In function int main (): bug.C:9: `funcPointer' undeclared (first use this function) bug.C:9: (Each undeclared identifier is reported only once bug.C:9: for each function it appears in.) bug.C:9: parse error before `)' However, the error message disappeared when I add the following type declaration: typedef void (*PTR_TO_FUNCTION_TYPE)(void); And then replace line 9 by: PTR_TO_FUNCTION_TYPE funcPointer; Can anyone tell me what I am doing wrong? By the way, the C++ compiler I was using is g++ (Version 1.37.1), on a SUN workstation. Please email response to my account. Thanks a lot. Andrew Choi Internet Address: c60c-2ca@web.berkeley.edu or c186cd@cory.berkeley.edu