Welcome, Guest. Please login or register.

Author Topic: Forgive the use of windows, but I need help !  (Read 1038 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline EinsteinTopic starter

  • Sr. Member
  • ****
  • Join Date: Dec 2004
  • Posts: 402
    • Show only replies by Einstein
Forgive the use of windows, but I need help !
« 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 ?
I have spoken !
 

Offline EinsteinTopic starter

  • Sr. Member
  • ****
  • Join Date: Dec 2004
  • Posts: 402
    • Show only replies by Einstein
Re: Forgive the use of windows, but I need help !
« Reply #1 on: May 17, 2005, 05:58:49 PM »
Dammit people, why dont you respond ?  :-(
I have spoken !
 

Offline Jose

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2869
    • Show only replies by Jose
Re: Forgive the use of windows, but I need help !
« Reply #2 on: May 17, 2005, 07:27:53 PM »
It's (* funcPtr)();

...
\\"We made Amiga, they {bleep}ed it up\\"
 

Offline Jose

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2869
    • Show only replies by Jose
Re: Forgive the use of windows, but I need help !
« Reply #3 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.
\\"We made Amiga, they {bleep}ed it up\\"
 

Offline EinsteinTopic starter

  • Sr. Member
  • ****
  • Join Date: Dec 2004
  • Posts: 402
    • Show only replies by Einstein
Re: Forgive the use of windows, but I need help !
« Reply #4 on: May 18, 2005, 01:24:54 PM »
Thanx for your responce, however, what's casting ?
I have spoken !
 

Offline EinsteinTopic starter

  • Sr. Member
  • ****
  • Join Date: Dec 2004
  • Posts: 402
    • Show only replies by Einstein
Re: Forgive the use of windows, but I need help !
« Reply #5 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 !!
I have spoken !
 

Offline EinsteinTopic starter

  • Sr. Member
  • ****
  • Join Date: Dec 2004
  • Posts: 402
    • Show only replies by Einstein
Re: Forgive the use of windows, but I need help !
« Reply #6 on: May 19, 2005, 01:08:51 PM »
I'm still interested of help if you people wonder.  :-D
I have spoken !
 

Offline Linchpin

  • Hero Member
  • *****
  • Join Date: May 2003
  • Posts: 1483
    • Show only replies by Linchpin
    • http://www.systemmedic.co.uk
Re: Forgive the use of windows, but I need help !
« Reply #7 on: May 19, 2005, 01:48:34 PM »
WinUAE Only... OS3.9 with 512mb ZIII ram ;)
 

Offline countzero

  • Hero Member
  • *****
  • Join Date: Mar 2005
  • Posts: 1938
    • Show only replies by countzero
    • http://blog.coze.org
Re: Forgive the use of windows, but I need help !
« Reply #8 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...
I believe in mt. Fuji
 

Offline EinsteinTopic starter

  • Sr. Member
  • ****
  • Join Date: Dec 2004
  • Posts: 402
    • Show only replies by Einstein
Re: Forgive the use of windows, but I need help !
« Reply #9 on: May 19, 2005, 02:18:35 PM »
Quote

LinchpiN wrote:



I asked for a simple declaration for a function-pointer, not your inner and outer state in front of a mirror dude.  :-)
I have spoken !
 

Offline EinsteinTopic starter

  • Sr. Member
  • ****
  • Join Date: Dec 2004
  • Posts: 402
    • Show only replies by Einstein
Re: Forgive the use of windows, but I need help !
« Reply #10 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.
I have spoken !