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++.Here is an example session:
>>> import clang.cindex
>>> idx = clang.cindex.Index.create()
>>> tu = idx.parse('/usr/include/math.h', ['-x', 'c++-header'])
>>> c = tu.cursor
>>> for d in c.get_children():
... print d.kind, d.spelling
...
CursorKind.TYPEDEF_DECL __int128_t
CursorKind.TYPEDEF_DECL __uint128_t
CursorKind.TYPEDEF_DECL __builtin_va_list
CursorKind.UNEXPOSED_DECL
Answering my own question:
On Fri, Oct 18, 2013 at 8:51 PM, Elliott Slaughter <elliotts...@gmail.com> wrote:
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++.Here is an example session:
>>> import clang.cindex
>>> idx = clang.cindex.Index.create()
>>> tu = idx.parse('/usr/include/math.h', ['-x', 'c++-header'])
>>> c = tu.cursor
>>> for d in c.get_children():
... print d.kind, d.spelling
...
CursorKind.TYPEDEF_DECL __int128_t
CursorKind.TYPEDEF_DECL __uint128_t
CursorKind.TYPEDEF_DECL __builtin_va_list
CursorKind.UNEXPOSED_DECLIt 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.
_______________________________________________
LLVM Developers mailing list
LLV...@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Hi Elliott,I am not sure why that is, but cfe...@cs.uiuc.edu is the correct place to discuss Clang design and implementation, so you should probably try asking there.On Oct 18, 2013, at 9:29 PM, Elliott Slaughter <elliotts...@gmail.com> wrote:Answering my own question:
On Fri, Oct 18, 2013 at 8:51 PM, Elliott Slaughter <elliotts...@gmail.com> wrote:
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++.Here is an example session:
>>> import clang.cindex
>>> idx = clang.cindex.Index.create()
>>> tu = idx.parse('/usr/include/math.h', ['-x', 'c++-header'])
>>> c = tu.cursor
>>> for d in c.get_children():
... print d.kind, d.spelling
...
CursorKind.TYPEDEF_DECL __int128_t
CursorKind.TYPEDEF_DECL __uint128_t
CursorKind.TYPEDEF_DECL __builtin_va_list
CursorKind.UNEXPOSED_DECLIt 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.