Re: [avr-gcc-list] calling function pointers via pointers ?

2005-09-30 Thread Anton Erasmus
On 29 Sep 2005 at 16:20, David Brown wrote: - Original Message - From: Vincent Trouilliez [EMAIL PROTECTED] On Thu, 2005-09-29 at 14:24 +0200, David Brown wrote: You've picked a chalenge with your complex menu structures, but you are definitely going about it the right way.

Re: [avr-gcc-list] calling function pointers via pointers ?

2005-09-29 Thread David Brown
Thank you so much chaps, after an hour experimenting, armed with all your suggestion, I have now improved my understanding of pointers again... and it now works... However, something still causes me trouble apparently The actual/complete declaration of my menu data type / structure is

Re: [avr-gcc-list] calling function pointers via pointers ?

2005-09-29 Thread David Brown
From: Vincent Trouilliez [EMAIL PROTECTED] [...] Problem: my function pointers are in an array, within a structure, which itself is accessed via pointers... oh dear. [...] //data type for a menu struct menu { .; .; int (*fp)()[]; //table to store all the pointers Err...

Re: [avr-gcc-list] calling function pointers via pointers ?

2005-09-29 Thread David Brown
Joerg Wunsch [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] stevech [EMAIL PROTECTED] wrote: Unspecified array sizes are a basic no-no on a microprocessor platform. The compiler strategies have to be simple and explicit, unlike elegant situations on multi-megabyte big computers.

Re: [avr-gcc-list] calling function pointers via pointers ?

2005-09-29 Thread Vincent Trouilliez
On Thu, 2005-09-29 at 09:25 +0200, David Brown wrote: It's a little easier to follow than all this void (*fp[])(void) crap, wouldn't you say? Thanks for pointing out that my code is crap ! ;-P I do mean it ! I mean, I am beginner... very motivated and eager to learn the art, but I can only do

Re: [avr-gcc-list] calling function pointers via pointers ?

2005-09-29 Thread David Brown
- Original Message - From: Vincent Trouilliez [EMAIL PROTECTED] On Thu, 2005-09-29 at 09:25 +0200, David Brown wrote: It's a little easier to follow than all this void (*fp[])(void) crap, wouldn't you say? Thanks for pointing out that my code is crap ! ;-P I didn't mean it

Re: [avr-gcc-list] calling function pointers via pointers ?

2005-09-29 Thread Vincent Trouilliez
On Thu, 2005-09-29 at 14:24 +0200, David Brown wrote: You've picked a chalenge with your complex menu structures, but you are definitely going about it the right way. Unconstrained arrays are almost certainly the most elegant way to deal with the structures - when you figure them out fully,

Re: [avr-gcc-list] calling function pointers via pointers ?

2005-09-29 Thread David Brown
- Original Message - From: Vincent Trouilliez [EMAIL PROTECTED] On Thu, 2005-09-29 at 14:24 +0200, David Brown wrote: You've picked a chalenge with your complex menu structures, but you are definitely going about it the right way. Unconstrained arrays are almost certainly the

Re: [avr-gcc-list] calling function pointers via pointers ?

2005-09-29 Thread Dave Hansen
From: Vincent Trouilliez [EMAIL PROTECTED] [...] What more could I possibly want ? Well, there is one thing actually: the pointer points to a function, any function. However if the item is actually a sub-menu, then the 'menu_item' structure needs to store a pointer to a 'menu' structure, so that

Re: [avr-gcc-list] calling function pointers via pointers ?

2005-09-29 Thread Vincent Trouilliez
On Thu, 2005-09-29 at 16:20 +0200, David Brown wrote: You're getting very close now - don't give up! David Thanks again David for the detailed review, and thanks everyone else :-) The forward declaration did the trick indeed, magic ! :o) So now the definition of my menus look like this. I

Re: [avr-gcc-list] calling function pointers via pointers ?

2005-09-29 Thread Vincent Trouilliez
I tried the '' sign, but I get this error: ui.c:63: warning: initialization discards qualifiers from pointer target type I am really lost as to how to specify the address of menu_sub in ui_menu_main Well, once I manage to initialise the main menu with the address of the sub menu,

Re: [avr-gcc-list] calling function pointers via pointers ?

2005-09-29 Thread Andy Warner
Vincent Trouilliez wrote: [...] ui.c:63: warning: initialization discards qualifiers from pointer target type I am really lost as to how to specify the address of menu_sub in ui_menu_main OK - I'm going to ask _you_ to do something, just to mix things up here: 1. realise it's a

Re: [avr-gcc-list] calling function pointers via pointers ?

2005-09-28 Thread Joerg Wunsch
Vincent Trouilliez [EMAIL PROTECTED] wrote: struct menu { .; .; int (*fp)()[]; //table to store all the pointers }; Better declare them in a prototyped fashion: int (*fp)(void)[]; //definition for a menu const struct menu __ATTR_PROGMEM__ menu_foo = {

RE: [avr-gcc-list] calling function pointers via pointers ?

2005-09-28 Thread Dave Hansen
From: Vincent Trouilliez [EMAIL PROTECTED] [...] Problem: my function pointers are in an array, within a structure, which itself is accessed via pointers... oh dear. [...] //data type for a menu struct menu { .; .; int (*fp)()[]; //table to store all the

Re: [avr-gcc-list] calling function pointers via pointers ?

2005-09-28 Thread Thomas Buchta
On Wed, 28 Sep 2005 14:29:02 +0200, Lars Noschinski [EMAIL PROTECTED] wrote: Hi Lars! In many of my applications I use a called function pointer within an array in program memory like such example code: typedef INT8S (*PF_KEYFUNCTION) (MAIN_SYSTEM_STATE_T *ptrSystemState); PF_KEYFUNCTION

Re: [avr-gcc-list] calling function pointers via pointers ?

2005-09-28 Thread Vincent Trouilliez
Thank you so much chaps, after an hour experimenting, armed with all your suggestion, I have now improved my understanding of pointers again... and it now works... However, something still causes me trouble apparently The actual/complete declaration of my menu data type / structure is :

Re: [avr-gcc-list] calling function pointers via pointers ?

2005-09-28 Thread Joerg Wunsch
Vincent Trouilliez [EMAIL PROTECTED] wrote: What's the trick ? None. You cannot have two arrays with unspecified size within the same object. The compiler needs to be able to compute the offset of each struct element at compile-time, and this offset needs to be the same for each instantiated

Re: [avr-gcc-list] calling function pointers via pointers ?

2005-09-28 Thread Dave Hansen
From: Vincent Trouilliez [EMAIL PROTECTED] [...] However, something still causes me trouble apparently The actual/complete declaration of my menu data type / structure is : struct menu { uint8_t options; //options to control the operation of the menu uint8_t nb;

RE: [avr-gcc-list] calling function pointers via pointers ?

2005-09-28 Thread stevech
: Wednesday, September 28, 2005 12:07 PM To: avr-gcc-list@nongnu.org Subject: Re: [avr-gcc-list] calling function pointers via pointers ? Vincent Trouilliez [EMAIL PROTECTED] wrote: What's the trick ? None. You cannot have two arrays with unspecified size within the same object. The compiler

Re: [avr-gcc-list] calling function pointers via pointers ?

2005-09-28 Thread Joerg Wunsch
stevech [EMAIL PROTECTED] wrote: Unspecified array sizes are a basic no-no on a microprocessor platform. The compiler strategies have to be simple and explicit, unlike elegant situations on multi-megabyte big computers. I disagree. Vincent was going to put a table of initialized structs into

RE: [avr-gcc-list] calling function pointers via pointers ?

2005-09-28 Thread Vincent Trouilliez
On Wed, 2005-09-28 at 21:18 -0700, stevech wrote: Unspecified array sizes are a basic no-no on a microprocessor platform. The compiler strategies have to be simple and explicit, unlike elegant situations on multi-megabyte big computers. Thanks chaps, it's a no-no then. I will just move the

RE: [avr-gcc-list] calling function pointers via pointers ?

2005-09-28 Thread Vincent Trouilliez
Thanks chaps, it's a no-no then. I will just move the strings out of the structure, or make them fixed size, by setting a limit to the number of items/options I can have in a menu. Replying to my post but, since my struct has two arrays, one of strings and one of pointers, and one of them MUST