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: Richard Urwin
Subject: Re: [avr-gcc-list] Pointer to a function in a structure in flash?
Date: Mon, 27 Oct 2003 19:36:29 +0000
User-agent: KMail/1.5

On Monday 27 Oct 2003 6:04 pm, Bob Paddock wrote:
> > 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.

Do these help?
I've taken out the parameters and simplified the structure, but I don't think 
I've changed the logic any.

-- 
Richard Urwin

reply via email to

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