Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!haven!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: pointers to pointers to functions Message-ID: <20136@mimsy.UUCP> Date: 12 Oct 89 18:00:04 GMT References: <8247@medusa.cs.purdue.edu> Distribution: usa Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 43 In article <8247@medusa.cs.purdue.edu> bouma@cs.purdue.EDU (William J. Bouma) writes: >I need a list of pointers to functions to be malloced. What is >the syntax? I declared this thing to hold it: > int (**f)(); % cdecl explain int (**f)() declare f as pointer to pointer to function returning int So far, so good: f can point to the first of `n' pointers to functions returning int. >And then I tried mallocing some space for it like this: > f = (int (**)()) malloc(n * sizof(*f)); Since you misspelled `sizeof' above, I have to conclude that this is not extracted directly from the source that gave you the error. Hence: >When the compiler hits that line I get this: > illegal lhs of assignment operator > unacceptable operand of & > warning: illegal pointer/integer combination, op = > cannot recover from earlier errors: goodbye! Were sizeof spelled correctly above, that line would be fine (provided that you have declared malloc() at some earlier point, but even otherwise, pcc would not complain). I must conclude that either your compiler is broken, or the text quoted above (with sizeof corrected) is not the text you fed to that compiler. >Also, C doesn't care if I call the function: > (*f[x])(); >or > (f[x])(); >ie. both of these work. Why? Is the first one the "correct" way? Both will work in any (proposed) ANSI C compiler, but the former is required by many older compilers. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@cs.umd.edu Path: uunet!mimsy!chris