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
NXC function pointers
-
- Posts: 358
- Joined: 01 Oct 2010, 06:37
- Location: Denmark
- Contact:
Re: NXC function pointers
Not eXactly C is basically C without pointers (and a few other differences). So you can't. (I'm not familiar with function pointers in C though.)
However I think it might be possible in the FW. I'm no expert on the NXT FW bytecode, but I think a variable is used to represent the function, perhaps you could change the value of this variable for interesting results?
However I think it might be possible in the FW. I'm no expert on the NXT FW bytecode, but I think a variable is used to represent the function, perhaps you could change the value of this variable for interesting results?
My blog: http://spillerrec.dk/category/lego/
RICcreator, an alternative to nxtRICeditV2: http://riccreator.sourceforge.net/
RICcreator, an alternative to nxtRICeditV2: http://riccreator.sourceforge.net/
Re: NXC function pointers
The NXT virtual machine does not support function pointers or recursively defined structures. As a result, neither does NXC.
John Hansen
John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
http://bricxcc.sourceforge.net/
Who is online
Users browsing this forum: No registered users and 4 guests