??? 02/26/11 11:42 Modified: 02/26/11 11:46 Read: times |
#181327 - issue with #define usage Responding to: ???'s previous message |
Praveen Kumar said:
Is there any issue with #define usage? Yes! As you should know, #define simply does text substitution: #define macro replacementsimply replaces every occurence of the text "macro" with the substitute text "replacement" - it has no regard for scope, data type, or anything else like that. Also, because the preprocessing happens before the compiler itself sees the code, it means that the compiler cannot generate any symbolic debug information for it. Why Netrino chose Rule #2 Anyone setting such a rule should explain it - what do they say? It certainly has the advantages of being strongly-typed but, as Per pointed out, it also has disadvantages in terms of both memory usage and code execution. As with anything in engineering, there is a tradeoff between the two - only you can decide which is the more important in your particular application... As Per also mentioned, you should also consider using an enum Again, this is textbook 'C' stuff - nothing to do with Keil or the 8051. I suggest you take some time to study http://c-faq.com/ |
Topic | Author | Date |
Multiple public definitions in code banking | 01/01/70 00:00 | |
single const byte in code | 01/01/70 00:00 | |
The meaning of 'const' in ANSI 'C' | 01/01/70 00:00 | |
Yes | 01/01/70 00:00 | |
Keil C51 isn't a C++ compiler | 01/01/70 00:00 | |
Coding Standard Rules - Netrino | 01/01/70 00:00 | |
Rule #2 is a bit broken or at least incompletely formulated | 01/01/70 00:00 | |
issue with #define usage | 01/01/70 00:00 | |
extern const code declaration | 01/01/70 00:00 | |
Insufficient detail | 01/01/70 00:00 | |
Conceptually wrong | 01/01/70 00:00 | |
Thanks, it's working ! | 01/01/70 00:00 | |
Why? | 01/01/70 00:00 | |
correction | 01/01/70 00:00 | |
Fundamental 'C' programming error! | 01/01/70 00:00 |