This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Displaying result of Macro evaluation

is there an easy way to see what the result is from something like the following...

#define ADC_MIN 1.8
#define ADC_MAX 2.4
#define ADC_MAX_VAL 255
#define ADC_LSB (double)(( ADC_MAX - ADC_MIN)/(double)ADC_MAX_VAL)
#define ADC_GAIN 0.5

#define ADC_VAL(x) ((((double)(v)) - ADC_MIN + (double)(ADC_GAIN)*ADC_LSB)/ADC_LSB)

#define WHAT_IS_THIS_VAL (unsigned char) ADC_VAL(100)

Of course I can crunch it all by hand but it would be nice to see what the preprocessor evaluates this to. I could go to where this is used and see what the value is but ideally I would like a list of symbols that contains the macro name and the value that is substituted for that macro.

I saw in doc the DIR command but wasn't able to get the result I wanted and I only see actual memory variables in the symbol list.

Thanks for any help in advance

Parents
  • As already noted, the Prepocessot just does text substitution - it does not evaluate anything.

    Do you think that statement is 100% accurate?

    Consider:

    #include <stdio.h>
    
    void main(void)
    {
    #if (1+1)==2
      printf("(1+1)==2 : Accuracy of advice is important!\n");
    #else
      printf("(1+1)!=2 : Accuracy of advice is not important!\n");
    #endif
    }
    

    Which text do you think will be printed?

Reply
  • As already noted, the Prepocessot just does text substitution - it does not evaluate anything.

    Do you think that statement is 100% accurate?

    Consider:

    #include <stdio.h>
    
    void main(void)
    {
    #if (1+1)==2
      printf("(1+1)==2 : Accuracy of advice is important!\n");
    #else
      printf("(1+1)!=2 : Accuracy of advice is not important!\n");
    #endif
    }
    

    Which text do you think will be printed?

Children