Get_includes does not find standard library headers

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.cppas follows:

#include <iostream>
#include <stdio.h>
#include "hello.h"

int main()
{
    std::cout << "Hello world\n";
}

And the file hello.hlooks like this:

#include <list>

I thought the code above would print vector, stdio.hand hello.hmaybe listmore if it takes into account transients. However, it only prints ./hello.h, explicitly ignoring the standard library headers.

- , . ? , , clang.cindex, ?

+4

Source: https://habr.com/ru/post/1611431/


All Articles