06-29-2016 10:26 AM
This is not a question, but a tip to others. I was so excited about this, that I had to share.
For a long time now, I've been using enum lists without typedeffing them. My variables that used these lists were simply typed as integers. The consequence of this is that in the debugger, I would see only numeric indexes that I would have to decode myself. Looked liks this.
Definition
enum { // system commands STEP_TYPE_INIT, STEP_TYPE_DELAY, STEP_TYPE_HV, STEP_TYPE_KV, STEP_TYPE_UA, STEP_TYPE_R, MAX_STEP_TYPES, };
Usage
typedef struct { int type; double parameter[MAX_NUM_PARMS]; } step_struct; script_struct script; script.step[7].type = STEP_TYPE_KV;
The above looks like this in the debugger, not very helpful.
Now if we simply typedef the enum and change the type of the variable member "type" to that new typdef, we get much easier debugging.
Definition
typedef enum { // system commands STEP_TYPE_INIT, STEP_TYPE_DELAY, STEP_TYPE_HV, STEP_TYPE_KV, STEP_TYPE_UA, STEP_TYPE_R, MAX_STEP_TYPES, } steptype_enum;
Usage
typedef struct { steptype_enum type; double parameter[MAX_NUM_PARMS]; } step_struct; script_struct script; script.step[7].type = STEP_TYPE_KV;