CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Function pointers

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
meebee
Guest







Function pointers
PostPosted: Thu May 20, 2004 7:53 pm     Reply with quote

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
dyeatman



Joined: 06 Sep 2003
Posts: 1912
Location: Norman, OK

View user's profile Send private message

Function Pointers
PostPosted: Fri May 21, 2004 9:27 am     Reply with quote

There have a LOT of discussions about pointers on the board! Search this board for function pointers and you will get a lot of info and some sample code!
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

Re: Function pointers
PostPosted: Fri May 21, 2004 9:59 am     Reply with quote

meebee wrote:
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


What is the application? Maybe there is a better solution that does not involve function pointers. The only place I can think of where function pointers would be the best solution would be in the creation of a multi tasking system for a complex system. Thats not the sort of thing you do with a PIC. I really am curious why you want to use function pointers.
meebee



Joined: 21 May 2004
Posts: 2

View user's profile Send private message

PostPosted: Fri May 21, 2004 4:14 pm     Reply with quote

This is the hardware platform I use:
http://particle.teco.edu/artefacts.html

The data that is transmitted over RF always has a certain type.
There are e.g. different control types/messages and depending on the application you have to respond differently.
So what I want to to is to use a dispatcher and a register_callback function. Then you can write your custom handler function, register it and it is invoked appropriately by the dispatcher.
My main goal is provide a development platform where other developers can write applications upon. With the aforementioned mechanism I can cleanly separate the underlying framework from the application that is written with it.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group