Date: Tue, 2 Dec 1997 19:18:19 -0800 (PST) Message-Id: <199712030318.TAA24651@adit.ap.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" To: Jonathan Villani , djgpp AT delorie DOT com From: Nate Eldredge Subject: Re: Pointer to a function & calling this function after... (VESA LIB) Precedence: bulk At 09:46 11/25/1997 GMT, Jonathan Villani wrote: >Hello, > >I am currently porting my VESA lib to DJGPP and i'm not able to do the >same thing that i have done in my lib written in Borland C++ 3.1. >My problem is that i want to have a pointer that contains the address of >my putpixel function depending on what mode i am (8bpp to 32bpp) each >one as a function. I want to call the RIGHT function (pointer) to put a >pixel using a call beacause i don't want to use a switch to check the >mode every single pix plot! The code you used was rather bizarre. A construct like `&foo()' does NOT work. Here is an example of how to use pointers to functions. Inline asm is not necessary. The ...'s should of course be replaced with actual code. void pix8(int x, int y, int c) { /* ... */} void pix24(int x, int y, int c) { /* ... */ } int main(void) /* main() must ALWAYS return int */ { void (*pix_func)(); if (want_pix8) pix_func = pix8; /* no `()'! */ else pix_func = pix24; /* call whichever function */ pix_func(100,200,3); return 0; } Nate Eldredge eldredge AT ap DOT net