<div dir="ltr"><p>Hello,</p><p>Please if I'm not using the correct email list, could you indicate me which one to use?<br></p><p>I'm currently busy with using libclang library.</p>

<p>My goal is to parse code that contains macro with parameters and to 
get the type of the macro parameters in order to make syntax coloration.</p>

<p>If we consider the following piece of code</p>

<pre><code><span>#define</span><span> MACRO</span><span>(</span><span>X</span><span>)</span><span> X

</span><span>typedef</span><span> </span><span>struct</span><span>
</span><span>{</span><span>
  </span><span>int</span><span> a</span><span>;</span><span>
</span><span>}</span><span> aType</span><span>;</span><span>

aType data</span><span>;</span><span>

</span><span>int</span><span> var </span><span>=</span><span> MACRO</span><span>(</span><span>data</span><span>.</span><span>a</span><span>);</span></code></pre>

<p>My goal is to be able to color the field <code>a</code> of the structure <code>aType</code> on the line <code>int var = MACRO(data.a)</code>. I.e. I would like to get the line, column and type whenever I'm getting a cursor over the field <code>a</code> of <code>data</code> variable.</p>

<p>The problem is that whenever I'm getting the cursor on the position of character <code>a</code>, its type is <code>CXCursor_MacroExpansion</code>. I've already tried to get the referenced cursor (via <code>clang_getCursorReferenced</code>) but then I'm getting a cursor type <code>CXCursor_MacroDefinition</code>.</p>

<p>I've also already tried to visit the child via <code>clang_visitChildren</code> but this returning the cursor itself as well, so it is not useful.</p>

<p>If I could get a cursor with type <code>CXCursor_MemberRefExpr</code> out of my cursor with type <code>CXCusor_MacroExtension</code> I would have what I need.</p>

<p>Does anyone have an idea how to actually get the info of expanded code iso getting <code>CXCursor_MacroExpansion</code>, whenever cursor is over a macro expansion?</p>

<p>Thanks a lot for your time and help.</p>

<p>Kind regards,</p>

<p>Laurent</p></div>