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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/30/05 19:30
Read: times


 
Msg Score: +1
 +1 Good Answer/Helpful
#96335 - In context
Responding to: ???'s previous message
Abhishek Singh said:
in previous posts, Andy stated:

The preprocessor has no business doing any maths at all:

I said it here; that's true.

But your example was
#if constant_expression 
<code> 
#else 
<code> 
#endif
I was talking about
#define Xtal 22.1184 
#define tic12 (12/Xtal) 
#define _10msec (65536 - ((1000 * 10) / tic12))

Now, clearly, the preprocessor does have to evaluate the constant_expression in your example in order to test the condition - but such expressions are restriced to integer-only maths (among other things).

But the #define macro names are different: as far as the preprocessor is concerned, anything that comes after the macro name is just treated as pure text; the preprocessor does not even know that they are expressions - let alone try to evaluate them!
All the preprocessor does with these definitions is to replace every occurrence of the macro name with whatever followed it on the definition line. No maths!

So yes, I missed the distinction between the two cases - what I said applies to the latter.

List of 31 messages in thread
TopicAuthorDate
defination under Keil            01/01/70 00:00      
   int/float            01/01/70 00:00      
   IAR PreProcessor VS Keil            01/01/70 00:00      
      confusion            01/01/70 00:00      
         just doing text subistituons I guess            01/01/70 00:00      
            un            01/01/70 00:00      
               preprocessor            01/01/70 00:00      
                  Some confusion abounds...            01/01/70 00:00      
                     Wrong again!            01/01/70 00:00      
                        Take is easy...            01/01/70 00:00      
                           The important bit...?            01/01/70 00:00      
         Floating-point not supported in eval            01/01/70 00:00      
      preprocessor maths            01/01/70 00:00      
         I was being carelessly loose............            01/01/70 00:00      
            Keil Test            01/01/70 00:00      
            Save you the trouble            01/01/70 00:00      
               Oh            01/01/70 00:00      
         preproccessor maths            01/01/70 00:00      
            ##########            01/01/70 00:00      
               thats the confusion            01/01/70 00:00      
                  In context            01/01/70 00:00      
                     Thanks            01/01/70 00:00      
                  Think about it            01/01/70 00:00      
   Aside - 'C' #define names            01/01/70 00:00      
      good coding practices            01/01/70 00:00      
   Thank you            01/01/70 00:00      
      Alternatively...            01/01/70 00:00      
         re: Alternatively...            01/01/70 00:00      
      Not a good idea            01/01/70 00:00      
         Not a good idea            01/01/70 00:00      
         floating point in ISRs            01/01/70 00:00      

Back to Subject List