View previous topic :: View next topic |
Author |
Message |
meebee Guest
|
Function pointers |
Posted: Thu May 20, 2004 7:52 pm |
|
|
PCH version 3.158
I wanted to write a dispatcher function, with an array storing pointes to callback functions. Given a certain event I wanted to call the appropriate callback function.
Unfortunately it seems that the pic c compiler doesnt support function pointers. E.g:
void do_nothing() {}
void main() {
void (*p)();
p = do_nothing;
p();
}
Gives me this error message:
Error 117: Improper use of a function identifier.
Did I miss something or is the compiler not capable with dealing of function pointers? Is there any workaround for this?
Any help appreciated,
Michael |
|
|
rwyoung
Joined: 12 Nov 2003 Posts: 563 Location: Lawrence, KS USA
|
|
Posted: Thu May 20, 2004 7:56 pm |
|
|
According to the readme.txt your version just misses pointer-to-function implementation. That as V3.160.
That said, it doesn't work that well (in my opinion) in any version since 3.160. Not sure how far back the discussion was (use the search feature to look for "function pointer" or "pointer to function") but PCM Programmer, RJ Hamlet, myself and probably a dozen others went back and forth about function pointers.
OK - editing the post because I found a few links.
The one I was remembering is
http://www.ccsinfo.com/forum/viewtopic.php?t=6843&highlight=pointer+function
And another promising one is
http://www.ccsinfo.com/forum/viewtopic.php?t=18345&highlight=function+pointer _________________ Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month! |
|
|
meebee
Joined: 21 May 2004 Posts: 2
|
|
Posted: Fri May 21, 2004 1:28 am |
|
|
Thanks for your quick reply.
I'll try v3.188 and see if it works (v3.190 seems to have many problems). |
|
|
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
Posted: Mon May 24, 2004 9:01 am |
|
|
look at pointer to funtion in CCS FAQ. They have a way to do it.
somewhat. |
|
|
|