Here enum is not a good idea if you have a switch case like:
switch (val) { /* val is uint8_t /
case OP_XXX: break;
case OP_YYY: break;
case OP_ZZZ: break;
}
Looks nice, but in debugging, you have no idea where we are going when you set a breakpoint at the switch. because the val is not an enum type, so debugger can't make the job easier for you.
Now it is much better:
switch (val) { / val is uint8_t /
case 0: / XXX /
break;
case 1: / YYY /
break;
case 2: / ZZZ */
break;
}
> Looks nice, but in debugging, you have no idea where we are going when you set a breakpoint at the switch. because the val is not an enum type, so debugger can't make the job easier for you.
The val may be a corrupted value which are not covered by any of the listed case. However, you will be able to identify what's going wrong right away by comparing the value with listed cases.
Yes, it is rare. but sometimes I do wish I haven't used enum.
Here enum is not a good idea if you have a switch case like:
switch (val) { /* val is uint8_t / case OP_XXX: break; case OP_YYY: break; case OP_ZZZ: break; }
Looks nice, but in debugging, you have no idea where we are going when you set a breakpoint at the switch. because the val is not an enum type, so debugger can't make the job easier for you.
Now it is much better:
switch (val) { / val is uint8_t / case 0: / XXX / break; case 1: / YYY / break; case 2: / ZZZ */ break; }