c++ - libclang: add compiler system include path (Python in Windows) -


following question , andrew's suggestions, trying have liblang add compiler system include paths (in windows) in order python code

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)      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) 

to completely parse c++ source files one

/* 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;   (i=numbers.begin(); i!=numbers.end(); ++i) {   total +=*i; }   return total/numbers.size();  } 

now, without compiler system include path set appropriately (using windows), following output:

cursorkind.using_directive using_directive 8 , 17 std cursorkind.var_decl var_decl 10 , 6 readfunction  process finished exit code 0  <diagnostic severity 4, location <sourcelocation file 'test.cpp', line 3, column 10>, spelling "'iostream' file not found"> 

unfortunately, cannot make sense (new in python , clang) of approach or how implement solution in python code.

i have tried ccsyspath, not have skills 'adjust windows'.

anyone knows how solve issue?


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -