??? 10/25/11 09:28 Read: times |
#184356 - Not all compilers are as good at generate warnings Responding to: ???'s previous message |
You shouldn't really assign numeric values - that kills much of the advantages with enumerators.
If the compiler will warn or not depends on used compiler, and what warning levels you have turned on. Another question is - will your compiler warn about: switch (my_enum_var) { case actionEmpty: break; case actionOn: break; case actionOff: break; //actionRegulate, <= case not handled case actionPulse: break; } With #define, the missing rule for actionRegulate can not be detected. Many compilers will inform that actionRegulate doesn't have an explicit match and that there isn't any garbage collect using a default case. The difference between enum and #define is that good use of enum always gives more information to the programmer. And use of enum will allow better compiler to produce additional type checking. The #define search/replace does not give any information to programmer or compiler about what set of values that are intended for a variable. |
Topic | Author | Date |
User entered recipes ??? | 01/01/70 00:00 | |
Just create array of regular rules | 01/01/70 00:00 | |
Thanks - that's great | 01/01/70 00:00 | |
programming language | 01/01/70 00:00 | |
programming language - not really | 01/01/70 00:00 | |
consider enum | 01/01/70 00:00 | |
thanks - implemented. | 01/01/70 00:00 | |
Intelligence | 01/01/70 00:00 | |
I must have a stupid compiler | 01/01/70 00:00 | |
Not all compilers are as good at generate warnings | 01/01/70 00:00 | |
no warning/error on the compiler | 01/01/70 00:00 | |
response from Raisonance | 01/01/70 00:00 | |
enumerations on 8051 | 01/01/70 00:00 | |
enums are 8bit by default on Raisonance | 01/01/70 00:00 | |
NULL | 01/01/70 00:00 | |
Could you show me the code | 01/01/70 00:00 | |
compatibility et al | 01/01/70 00:00 | |
why change pointer to CODE? | 01/01/70 00:00 | |
enum advantage | 01/01/70 00:00 | |
user page does not work (at least for me) | 01/01/70 00:00 | |
try it now | 01/01/70 00:00 | |
re: enumerations on 8051 | 01/01/70 00:00 | |
Article on Hierarchical Menu Structure | 01/01/70 00:00 |