Macro expansion

Hello All,

I have a situation to expand a macro and I have succeeded by
extracting a constant value using clang::MacroInfo
But if a user gives a expression then how can we evaluate the macro value?

#define S 16
#define O 4
#define C S/O

In the above example I need the evaluate S/O expression and use the
value for my processing.
Can someone point how can we do this?

Thanks in advance.



Unfortunately the pre processor amounts to not much more than text
manipulation and as such it won't evaluate expressions. In your example
`C` will hold the value `16/4`. If you want to have more than that,
then you will likely need to add a pre-build step to your build
process, Similar(but very different) to TableGen.

Nathan James

Hi Nathan James,

Thanks for the reply.
I just want 16/4. Is there any way to get that other than using
clang::MacroInfo getReplacementToken()