Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!elroy!orion.cf.uci.edu!uci-ics!zola.ics.uci.edu!schmidt From: schmidt@zola.ics.uci.edu (Doug Schmidt) Newsgroups: comp.lang.c++ Subject: Re: Passing array of function pointers Message-ID: <11888@paris.ics.uci.edu> Date: 12 Apr 89 20:23:37 GMT References: Sender: news@paris.ics.uci.edu Reply-To: Doug Schmidt Distribution: comp.lang.c++ Organization: University of California at Irvine: ICS Dept. Lines: 43 In article mleisher@nmsu.edu (Mark Leisher) writes: ++ Can anyone tell me what is wrong with this: ++ [original program omitted, revised version presented below] Sure. First of all, you forgot the `void' before the formal declaration of (*f[])(int, int) in function fill. Secondly, cfront 1.2.1 and G++ have problems grokking complex pointer-to-function-etc declarations. Putting the keyword `auto' in strategic places provides enough context to the parser so that the program is properly recognized. The following revised version compiles correctly with both cfront 1.2.1 and G++. I don't know if cfront 2.0 fixes this problem. Doug ---------------------------------------- #include void junk( int a, int b ) { cout << a << "\n" << b; } void fill( auto void (*f[])(int, int) ) { int i; for ( i = 0; i < 128; i++ ) f[i] = junk; } main() { auto void (*func_tbl[128])(int, int); fill( func_tbl ); } ---------------------------------------- -- On a clear day, under blue skies, there is no need to seek. And asking about Buddha +------------------------+ Is like proclaiming innocence, | schmidt@ics.uci.edu | With loot in your pocket. | office: (714) 856-4043 |