NXC function pointers
Posted: 16 Nov 2010, 19:05
Hi,
I want to use a menu like the standard menu from NXT 2.0 brick.
Unfortunately I can't find a system call to reuse the existing one
Therefore I tried to implement my own, but it I couldn't declare a function pointer:
typedef struct {
string label;
string ricPath;
bool (*onEnter)(int *item); // compile error
} MenuItem;
Q1:
Doesn't support NXC function pointer at all?
If so, is there any "trick" to deal with something like a callback?
(Sorry if it is a stupid question - I'm not a C developer)
Q2: How can I define struct types which depends on each other ?
typedef struct { B b; } A;
typedef struct { A a; } B;
// In my case: "Menu" contains "MenuItem" and "MenuItem *could* contain a "Menu" (as sub-menu)
Thanks in advance
Thomas
I want to use a menu like the standard menu from NXT 2.0 brick.
Unfortunately I can't find a system call to reuse the existing one
Therefore I tried to implement my own, but it I couldn't declare a function pointer:
typedef struct {
string label;
string ricPath;
bool (*onEnter)(int *item); // compile error
} MenuItem;
Q1:
Doesn't support NXC function pointer at all?
If so, is there any "trick" to deal with something like a callback?
(Sorry if it is a stupid question - I'm not a C developer)
Q2: How can I define struct types which depends on each other ?
typedef struct { B b; } A;
typedef struct { A a; } B;
// In my case: "Menu" contains "MenuItem" and "MenuItem *could* contain a "Menu" (as sub-menu)
Thanks in advance
Thomas