View #define (d) macro

sorry, i’m not sure if this is the correct section for this question…
i’m looking for a manner to view the result of my #define statement (the final value).
Is this possible in IDE, or in compile listing?

the current problem is that i expect the same result by this macros, but it is’nt:
first:
#define SPICLK_PORT SPI0_CLK>>5
#define SPICLK_OFFSET SPICLK_PORT<<5
second:
#define SPICLK_OFFSET SPI0_CLK&0xE0

I would be happy, however, to find a general method to see the definitions and values of the #define statements.

thanks

You should be able use #pragma message message-you-want-to-display to output compile-time messages and variable values, etc.

More on the message #pragma here.

1 Like

thanks for your suggestion, but i’m not able to do it working…
the statement #pragma message "OFFSET is: " SPICLK_OFFSET simply output in compile terminal:
#pragma message "OFFSET is: " SPICLK_OFFSET

where am i wrong?

Preprocessor macros are … :face_with_symbols_over_mouth:

Anyway, it can be done but it’s more complex:

#define XSTR(x) STR(x)
#define STR(x) #x

#pragma message "OFFSET is: " XSTR(SPICLK_OFFSET)
4 Likes

it works… thanks.
i also discover another solution (not so fine…) using preprocessor options -dM -E , compiling and inspect the output file .o

thank you

2 Likes