|
|
View previous topic :: View next topic |
Author |
Message |
MikeW
Joined: 15 Sep 2003 Posts: 184 Location: Warrington UK
|
Pointers to functions |
Posted: Tue Feb 06, 2007 11:33 am |
|
|
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
|
|
Posted: Tue Feb 06, 2007 4:54 pm |
|
|
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
|
|
Posted: Fri Feb 09, 2007 6:03 am |
|
|
I could really do with some help on this.
Mike |
|
|
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
|
Posted: Fri Feb 09, 2007 6:15 am |
|
|
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
|
|
Posted: Fri Feb 09, 2007 6:49 am |
|
|
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. |
|
|
|
|
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
|