avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Pointer to a function in a structure in flash?


From: Bob Paddock
Subject: Re: [avr-gcc-list] Pointer to a function in a structure in flash?
Date: Mon, 27 Oct 2003 13:04:26 -0500
User-agent: Opera7.21/Win32 M2 build 3218



Unfortunately this could look a bit messy without doing
some additional typedefs beforehand. I would suggest this
(sorry for the gratuitous wrapping):

typedef uint16_t (*functype_t)(CONST char * tok_buf, CONST
char * tok_ptr);

typedef struct
{
     PGM_P command;
     functype_t function;
}str_func_entry;


retval = (*((functype_t)(pgm_read_word(&cmd_func_table
[i].function))))((char const *)token, (char const *)tokptr);

this is untested of course.

GCC generates warning:
 initialization from incompatible pointer type

when I try to iniz. the array.

IAR is a bit more specific:

 Warning[Pe144]: a value of type
 "unsigned short (*)(char const *, char const *)"
 cannot be used to initialize an entity of type
"unsigned short (*(*)(char const *, char const *))(char const *, char const *)"

I tried retypeing one function to functype_t and that just turned in to yet more errors. Don't really want to have to go through all the functions in the table and retype them if
I don't have to.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]