apalrd:
I’ve always been a fan of “good” programming, dividing up code into logical subsystems, using enums to describe states and commands (instead of strings or numbers). Thus, I have a C/H file for each subsystem, with a poke function, and functions to pass data into and out of the subsystem (e.g. an arm has a poke, which does the closed-loop control, and a function to set the state, plus a few other functions).
peek & poke, reminds me of my C64 days.
-It dosen’t seem to mind me creating a typedef struct, but it won’t let me set the return type of a function to that structure. In easyC, I passed the variables in as pointers and modified them in the function, but robotC won’t allow me to do it in the C way, so I’m trying to pass data out by returning a structure. Is there any reason for it to not let me return a struct?
There are no pointers in RobotC. There is no stack in RobotC. Functions in RobotC do not work the same as “normal” C. What can I tell you, it’s not real C.
-It dosen’t seem to mind most of the typedef enums, but one of them (arm_idg_sen_t) it hates. I declare the enum in the header file (no errors), then create two of them in my arm implementation file, to which it says;
**Error**:Undefined variable 'arm_idg_arm_sen_t'. 'short' assumed.
**Error**:Expected->';'. Found 'idg_trust'
**Error**:Executable statements not valid in 'main' declaration block
**Error**:Undefined variable 'idg_trust'. 'short' assumed.
**Error**:Expected->';'. Found ','
**Error**:Unexpected scanner token-> ','
**Error**:Undefined variable 'idg_debug_last'. 'short' assumed.
Would have to seen the code to comment.
You cannot compare an enum to a short, cast the enum like. for example.
typedef enum {
kVersions = 0,
kJoystickTest = 1,
} TestMode;
...
...
void MyFunction()
{
int foo, bar;
if( foo == (short)kVersions )
bar = 3;
...
}
or (in this case) declare foo as a “TestMode”.
I’m afraid you just have to get used to the fact that RobotC is very much a subset of the C language.