Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!ucsd!swrinde!cs.utexas.edu!uunet!ingr!hammondp From: hammondp@ingr.com (Paul Hammond) Newsgroups: comp.graphics Subject: Re: Function pointer help Message-ID: <6907@ingr.com> Date: 16 Oct 89 18:32:41 GMT References: <3003@ndsuvax.UUCP> Distribution: comp.lang.c Organization: Intergraph Corp. Huntsville, Al Lines: 41 in article <3003@ndsuvax.UUCP>, nebakke@ndsuvax.UUCP (Jeff Bakke) says: > Posted: Fri Oct 13 00:02:03 1989 > > I have been working with function pointers in a program of mine and > have run into a stumper. Maybe I'm just not reading the manuals > correctly but what syntax do I use for the following setup: > > /* declaration */ > void (*border)(); /* a function pointer to a window border function */ > > ... > > void set_user_border(void *user_border){ > > border = user_border; > } > > Now the problem occurs when I compile in that it returns an error > (turbo c 2.0 by the way) stating that I need a storage type or something > like that. [ stuff deleted ] > I've tried (void (*user_border)()) but that still crashes. The second form : void set_user_border (void (*user_border)()) { ... } should work. Perhaps there is some complicating factor. Look for all the usual problems (missing semicolon, unmatched braces, comment delimiters etc.). Try it all by itself - without other code and declarations. This works with a Green Hills compiler on an Intergraph workstation. I've got TC2 at home but haven't tried this there. Paul L. Hammond ingr!b17b!ocelot!paul