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

Pointers to functions

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



Joined: 15 Sep 2003
Posts: 184
Location: Warrington UK

View user's profile Send private message

Pointers to functions
PostPosted: Tue Feb 06, 2007 11:33 am     Reply with quote

I need a bit of help on this.

I have found several good threads on how to parse an rs232 command line, and act upon it.

Trampas, and Mark are the Gurus on this.

I am trying to get the code below to compile, but it throws up the error "expression must evaluate to a constant"


below is the code in question.

the original thread is :-
http://www.ccsinfo.com/forum/viewtopic.php?t=20416&postdays=0&postorder=asc&start=0

page 2 is the important page

void version()
{
printf(OutputPC," version function \n\r");
} // end of function


void build()
{
printf(OutputPC," build function \n\r");
} // end of function

void BCOM()
{
printf(OutputPC," BCOM function \n\r");
} // end of function

void CAMR()
{
printf(OutputPC," CAMR function \n\r");
} // end of function


static Command CommandData[] =
{
{"ver",version}, //********** fails here ***********
{"build",build},
{"BCOM=",BCOM},
{"CAMR=",CAMR},
{"\0",0}}
};


static COMMAND_DATA CommandData[] =
{

/* application commands */
{ { "ver" }, VersionCommand, { "sofware version" } },
{ { "abus" }, ABUSCommand, { "sends command out abus" } },
{ { "input" }, InputCommand, { "input status" } },
{ { "photocell" }, PhotocellCommand, { "photocell status" } },
{ { "data" }, DataCommand, { "dump program data" } },
{ { "restore" }, ReInitCommand, { "restore defaults" } },
{ { "restart" }, RestartCommand, { "restart device" } },
{ { "dump" }, EEPROMDumpCommand,{ "dumps the contents of the eeprom" } },
{ { "host" }, HostModeCommand, { "allows this device to act as host" } },
{ { "??" }, VHelpCommand, { "verbose help" } },
{ { "?" }, THelpCommand, { "terse help" } },
{ { NULL }, NULL, { NULL } },
};
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Feb 06, 2007 4:54 pm     Reply with quote

Those two guys have mixed CCS and C18 code throughout the thread.
Sometimes it's not clear which one they're talking about.
MikeW



Joined: 15 Sep 2003
Posts: 184
Location: Warrington UK

View user's profile Send private message

PostPosted: Fri Feb 09, 2007 6:03 am     Reply with quote

I could really do with some help on this.

Mike
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Fri Feb 09, 2007 6:15 am     Reply with quote

Mike, I really hate to break these news. But v3 never supported function pointers and v4 might support them eventually, but right now function pointers in v4 are full of bugs.

I wish I were wrong on this one.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Fri Feb 09, 2007 6:49 am     Reply with quote

Also read the PICC manual chapter "How do I make a pointer to a function?" on why function pointers are not supported and a possible workaround.
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