libclang: Compiler-System-Include-Pfad hinzufügen (Python in Windows)

Folgend diesemFrag und Andrew's Vorschläge, ich versuche, @ zu hab liblang add Das Compilersystem enthält Pfade (unter Windows), um meinen Python-Code zu erhalten

import clang.cindex

def parse_decl(node):
    reference_node = node.get_definition()
    if node.kind.is_declaration():
        print(node.kind, node.kind.name, 
              node.location.line, ',', node.location.column, 
              reference_node.displayname)

    for ch in node.get_children():
        parse_decl(ch)

# configure path
clang.cindex.Config.set_library_file('C:/Program Files (x86)/LLVM/bin/libclang.dll')

index = clang.cindex.Index.create()
trans_unit = index.parse(r'C:\path\to\sourcefile\test.cpp', args=['-std=c++11'])

parse_decl(trans_unit.cursor)

tovollständi parse C ++ - Quelldateien wie diese

/* test.cpp
*/
#include <iostream>
#include <vector>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <iomanip>

using namespace std;

void readfunction(vector<double>& numbers, ifstream& myfile)
{

  double number;
  while (myfile >> number) {
  numbers.push_back(number);}

}

double meanfunction(vector<double>& numbers)
{

  double total=0;
  vector<double>::const_iterator i;
  for (i=numbers.begin(); i!=numbers.end(); ++i) {
  total +=*i; }
  return total/numbers.size();

}

Nun, ohne dass das Compiler-System den Pfad entsprechend eingerichtet hat (unter Windows), erhalte ich die folgende Ausgabe:

CursorKind.USING_DIRECTIVE USING_DIRECTIVE 8 , 17 std
CursorKind.VAR_DECL VAR_DECL 10 , 6 readfunction

Process finished with exit code 0

<Diagnostic severity 4, location <SourceLocation file 'test.cpp', line 3, column 10>, spelling "'iostream' file not found">

Leider kann ich keinen Sinn machen (neu in Python und Clang) von diesemAnsat oder wie man das umsetztLösun in meinem Python-Code.

Ich habe auch versucht ccsyspath, aber ich kann es nicht für Windows anpassen.

Weiß jemand, wie man dieses Problem löst?

Antworten auf die Frage(2)

Ihre Antwort auf die Frage