Python 叮当响的cindex罐头';在未保存的_文件中找不到头
我试图在Python中使用Python 叮当响的cindex罐头';在未保存的_文件中找不到头,python,clang,Python,Clang,我试图在Python中使用clang.cindex,但当我尝试传入一个伪头时,它不起作用: import sys from clang import cindex tu = cindex.Index.create().parse('t.cc', args=[], unsaved_files=[ ('t.h', ''), ('t.cc', '#include "t.h"'), ]) for diag in tu.diagnostics: sys.stderr.write(d
clang.cindex
,但当我尝试传入一个伪头时,它不起作用:
import sys
from clang import cindex
tu = cindex.Index.create().parse('t.cc', args=[], unsaved_files=[
('t.h', ''),
('t.cc', '#include "t.h"'),
])
for diag in tu.diagnostics:
sys.stderr.write(diag.format() + "\n")
我收到的错误是:
t.cc:1:10: fatal error: 't.h' file not found
发生了什么事?为什么它能找到
t.cc
而不能找到t.h
?结果表明,这是因为缺少/
前缀。显然,路径没有标准化
这很好:
import sys
from clang import cindex
tu = cindex.Index.create().parse('./t.cc', args=[], unsaved_files=[
('./t.h', ''),
('./t.cc', '#include "t.h"'),
])
for diag in tu.diagnostics:
sys.stderr.write(diag.format() + "\n")