loarabia / Clang-tutorial

A collection of code samples showing usage of clang and llvm as a library
Other
754 stars 122 forks source link

CItutorial3.cpp not finding #includes #29

Open samasri opened 7 years ago

samasri commented 7 years ago

Hello,

I am having trouble running the CItutorial3.cpp. First, the code doesn't compile since the InitializePreprocessor() function (screenshot attached). Hence I added the missing argument and made few changes to adapt the code to my directories. However, when I run the output CItutorial3, it gives me another error (screenshot attached) although I checked and made sure that stdio.h is in /usr/include/. I also made few changes to the Makefile to adapt it to my directory paths. I'm working on Ubuntu 16.04 on VirtualBox.

error1 error2 source code.zip

konigsberg commented 6 years ago

I met the same problem. I think it's because the HeaderSearch instance is not registered to the preprocessor instance, so the compiler instance knows nothing about the header search settings. I finally turn to modify the tutorial4.cpp and include the headers successfully. The function clang::ApplyHeaderSearchOption should be added to apply the header search options setting to the header search instance. Also the constructor of preprocessor now needs an additional MemoyBufferCache parameter.