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: E . Weddington
Subject: Re: [avr-gcc-list] Pointer to a function in a structure in flash?
Date: Mon, 27 Oct 2003 18:22:28 GMT

> 
> 
> > 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
an> d 
> retype them if
> I don't have to.

Ok, how are you defining cmd_func_table? Does it reside in 
RAM or Flash? How are you initializing it?

Eric







reply via email to

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