[cfe-dev] clang_parseTranslationUnit2(), "true", and libclang's header search path

Jacob Carlborg via cfe-dev cfe-dev at lists.llvm.org
Sat Jun 3 09:17:56 PDT 2017


On 2017-06-03 13:48, W. Michael Petullo via cfe-dev wrote:
> I am writing a program which parses other programs written in C. When
> I run my program, I find that it fails to find some key system headers
> such as stdbool.h.

IIRC, stdbool.h is a Clang internal header file. They are searched for 
relative to the binary.

In my tool I solved this by embedding some of the internal header files 
into the executable [1][2]. Then pass them to libclang as virtual files 
using CXUnsavedFile [3][4][5].

[1] https://github.com/jacob-carlborg/dstep/blob/master/clang/Compiler.d#L26

[2] 
https://github.com/jacob-carlborg/dstep/blob/master/clang/Compiler.d#L37-L38

[3] https://github.com/jacob-carlborg/dstep/blob/master/clang/Compiler.d#L54

[4] 
https://github.com/jacob-carlborg/dstep/blob/master/clang/Compiler.d#L53-L54

[5] 
https://github.com/jacob-carlborg/dstep/blob/master/dstep/driver/Application.d#L166

-- 
/Jacob Carlborg




More information about the cfe-dev mailing list