I recently got robotC because I was having issues with the autonomous execution in easyC. I actually wrote all of my code in C, then use the user code blocks to call my C code in each of the 3 easyC functions (so all of my code was actually in other C and H files).
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).
As easyC actually uses GCC to compile, it wasn’t hard to just use C constructs to define things (e.g. typedef enum) or pass pointers into things, as GCC supports C very well.
I am now trying to port my code into robotC (to make use of the better debugging functions, faster downloads, and better threading, and because of the issues I had with easyC). I am not doing anything really complex (in my eyes), but sometimes it’s just easier to pass a pointer to something than to look back to a variable in global memory.
However, robotC is yelling at me for various things which are valid in C. I’ve got it down to only about 20 errors (and a bunch of warnings which I can ignore for now):
-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?
-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.
Which is strange because another typedef enum defined in the same header file (arm_state_t) is declared only a few lines above I declare the arm_idg_sen_t’s, with no errors there.
It also warns every time I do an operation on idg_trust and idg_debug_last that I can’t use = or == on “short” or “arm_idg_sen_t”