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 08:34
Read: times


 
#184354 - Intelligence
Responding to: ???'s previous message
The preprocessor is stupid. It is just a glorified automatic search/replace engine.

The compiler, on the other hand, knows about data types.

So a good compiler can generate warnings if you have a switch statement that misses handling of one or more enum values - it would not know anything if you used #define.

Since enum represents data types, you can specify these data types when you create variables or member fields of structures. If you program with #define, you must settle for char, int, ... as data type. But a field of type "unsigned char" does not tell the reader that the field is expected to only contain valid action types. A field of type "Action" will tell the developer what is expected. And will allow the compiler to generate a warning if you try to assign a value not part of the "Action" enumeration.

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