Amiga.org

Operating System Specific Discussions => Amiga OS => Amiga OS -- Development => Topic started by: Einstein on May 17, 2005, 05:11:56 PM

Title: Forgive the use of windows, but I need help !
Post by: Einstein on May 17, 2005, 05:11:56 PM
I've recently resumed (!) some C programming (in windows though), now the problem I've ran into is this: I'm trying to access a function through a pointer to it by declaring the pointer as void and then try to call the function with:


*funcPtr();

and:

*(funcPtr)();

and even:

(*(funcPtr))();

Yes, I realize I'm drunk ( :-D ), so tell me, how do I do ?
Title: Re: Forgive the use of windows, but I need help !
Post by: Einstein on May 17, 2005, 05:58:49 PM
Dammit people, why dont you respond ?  :-(
Title: Re: Forgive the use of windows, but I need help !
Post by: Jose on May 17, 2005, 07:27:53 PM
It's (* funcPtr)();

...
Title: Re: Forgive the use of windows, but I need help !
Post by: Jose on May 17, 2005, 08:48:59 PM
BTW, that probably won't work either I don't think C allows using a void * as a function pointer. Try to do some casting first.
Title: Re: Forgive the use of windows, but I need help !
Post by: Einstein on May 18, 2005, 01:24:54 PM
Thanx for your responce, however, what's casting ?
Title: Re: Forgive the use of windows, but I need help !
Post by: Einstein on May 18, 2005, 01:28:37 PM
Quote

Jose wrote:
BTW, that probably won't work either I don't think C allows using a void * as a function pointer.


That's pretty stupid is'nt it ? WHY wouldnt the compliler
allow such accessing one figures !!
Title: Re: Forgive the use of windows, but I need help !
Post by: Einstein on May 19, 2005, 01:08:51 PM
I'm still interested of help if you people wonder.  :-D
Title: Re: Forgive the use of windows, but I need help !
Post by: Linchpin on May 19, 2005, 01:48:34 PM
(http://images.amazon.com/images/P/0764508350.01.LZZZZZZZ.jpg)
Title: Re: Forgive the use of windows, but I need help !
Post by: countzero on May 19, 2005, 01:57:21 PM
http://www.newty.de/fpt/fpt.html#defi

google and you shall find

casting is casting a type to a pointer. like, you can declare the function parameter as a void pointer, then you can cast it to a specific type and use it.

int myWindozeFunction (void * groovy, int what)

if (what == 1)
int * myIntPtr = (int *) groovy;

something like this...
Title: Re: Forgive the use of windows, but I need help !
Post by: Einstein on May 19, 2005, 02:18:35 PM
Quote

LinchpiN wrote:
(http://images.amazon.com/images/P/0764508350.01.LZZZZZZZ.jpg)



I asked for a simple declaration for a function-pointer, not your inner and outer state in front of a mirror dude.  :-)
Title: Re: Forgive the use of windows, but I need help !
Post by: Einstein on May 19, 2005, 02:24:24 PM
Quote

countzero wrote:
http://www.newty.de/fpt/fpt.html#defi

google and you shall find

casting is casting a type to a pointer. like, you can declare the function parameter as a void pointer, then you can cast it to a specific type and use it.

int myWindozeFunction (void * groovy, int what)

if (what == 1)
int * myIntPtr = (int *) groovy;

something like this...



Thank you, appreciate the help. (http://www.amiga.org/images/subject/icon14.gif)