<div dir="ltr">On Mon, Oct 14, 2013 at 9:48 PM, Alexander Basov <span dir="ltr"><<a href="mailto:coopht@gmail.com" target="_blank">coopht@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello.<div>Could somebody help me with macro expansion?</div><div><br></div><div>I have a header with the following macroses defined:</div>
<div><br></div><div>#define foo(x) x + 2</div><div>#define A 1</div>
<div>#define B foo(A)</div><div><br></div><div>And I need get the following map:</div><div>A = 1</div><div>B = 3</div><div><br></div><div>How can I do it?</div></div></blockquote><div><br></div><div>One way:</div><div><br>
</div><div>#include "your_header.h"</div><div><br></div><div>int main() {</div><div> printf("A = %d\nB = %d\n", A, B);</div><div> return 0;</div><div>}</div><div><br></div><div>What additional constraints do you have? Do you need to do this using the Clang C++ API for some reason? Do you know in advance the names of the macros that you want to evaluate?</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>I'm ale to get list of MacroInfo * classes with PPCallbacks or get it with Preprocessor::macro_begin() iterator, but I don't know how to get expaneded value.</div>
<div><br></div><div>Thank you in advance.</div><span class="HOEnZb"><font color="#888888"><div><div><br></div>-- <br>Alexander<br>
</div></font></span></div>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div></div>