c60c-2ca@WEB.berkeley.edu (03/18/90)
I discovered the following bug (or is it?) while trying to compile the following program: void print(void) { ; // dummy statement } int main(void) { void (*funcPointer)(void); // This is line 8 funcPointer = print; funcPointer(); (*funcPointer)(); return 0; } Here is what I got when I tried to compile it... bug.c: In function int main (): bug.c:8: `funcPointer' undeclared (first use this function) bug.c:8: (Each undeclared identifier is reported only once bug.c:8: for each function it appears in.) bug.c:8: parse error before `)' However, if I add the type definition: typedef (*PTR_TO_FUNCTION)(void); And then replace line 8 with: PTR_TO_FUNCTION funcPointer; The program compiles. Is there something I am doing wrong? By the way, the compiler I was using is g++ (version 1.37.1) on a SUN workstation. Please email response to my account. Thanks. Andrew Choi Internet Address: c60c-2ca@web.berkeley.edu or c186cd@cory.berkeley.edu