Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
10/25/11 07:48
Read: times


 
Msg Score: +1
 +1 Good Answer/Helpful
#184352 - consider enum
Responding to: ???'s previous message
I would recommend that you make use of the wonderful enum construct when you need to enumerate integer constants.

You should try to limit the use of #define to situations where enum can not be used - such as when you want to map a function name, a sequence of instructions, a text string or similar.

The following is nicer to use than a sequence of #define. If you do need to hard-code the mapping of symbol to integer value, then you can explicitly add a " = 1" or similar.

enum {
    actionEmpty,
    actionOn,
    actionOff,
    actionRegulate,
    actionPulse
};


Above is handled by the compiler, while below constructs are handled by the preprocessor:
#define RULE_ACTION_ON          1
#define RULE_ACTION_OFF         2
#define RULE_ACTION_REGULATE    3
#define RULE_ACTION_PULSE       4


List of 23 messages in thread
TopicAuthorDate
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      

Back to Subject List