I play with Python bindings to libclang. I'm currently trying to perform some very simple tasks, like finding all the headers included in a C ++ file. The code I use is as follows:
from clang.cindex import Index
index = Index.create()
tu = index.parse("hello.cpp", args=["-std=c++14"])
for it in tu.get_includes():
print(it.include.name)
The file is hello.cpp
as follows:
#include <iostream>
#include <stdio.h>
#include "hello.h"
int main()
{
std::cout << "Hello world\n";
}
And the file hello.h
looks like this:
#include <list>
I thought the code above would print vector
, stdio.h
and hello.h
maybe list
more if it takes into account transients. However, it only prints ./hello.h
, explicitly ignoring the standard library headers.
- , . ? , , clang.cindex
, ?