<div dir="ltr">On Sun, Oct 20, 2013 at 3:33 PM, Mark Lacey <span dir="ltr"><<a href="mailto:mark.lacey@apple.com" target="_blank">mark.lacey@apple.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 style="word-wrap:break-word">Hi Elliott,<div><br><div><div class="im"><div>On Oct 18, 2013, at 9:29 PM, Elliott Slaughter <<a href="mailto:elliottslaughter@gmail.com" target="_blank">elliottslaughter@gmail.com</a>> wrote:</div>
<br><blockquote type="cite"><div dir="ltr">Answering my own question:<br><div><br>On Fri, Oct 18, 2013 at 8:51 PM, Elliott Slaughter <span dir="ltr"><<a href="mailto:elliottslaughter@gmail.com" target="_blank">elliottslaughter@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"><div>I'd like to parse a C++ header file (say, math.h) with the Clang bindings for Python. (Yes, I know math.h is technically a C header, but for my purposes I want to pretend that it is C++.) For some reason, Clang is able to parse the file as C, but not as C++.<br>
<br></div>Here is an example session:<br><br>>>> import clang.cindex<br>>>> idx = clang.cindex.Index.create()<br>>>> tu = idx.parse('/usr/include/math.h', ['-x', 'c++-header'])<br>
>>> c = tu.cursor<br>>>> for d in c.get_children():<br>... print d.kind, d.spelling<br>... <br>CursorKind.TYPEDEF_DECL __int128_t<br>CursorKind.TYPEDEF_DECL __uint128_t<br>CursorKind.TYPEDEF_DECL __builtin_va_list<br>
CursorKind.UNEXPOSED_DECL <br></div></blockquote><div><br></div><div>It would seem that the contents on the entire module are hidden inside this UNEXPOSED_DECL. I'd be interesting in knowing why that is, but for now at least I seem to have solved my problem.<br>
</div></div></div></div></div></blockquote><div><br></div></div>I am not sure why that is, but <a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a> is the correct place to discuss Clang design and implementation, so you should probably try asking there.</div>
</div></div></blockquote><div><br></div><div>Thanks for the pointer. Sorry about the spam.<br></div></div><br>-- <br>Elliott Slaughter<br><br>"Don't worry about what anybody else is going to do. The best way to predict the future is to invent it." - Alan Kay
</div></div>