Something like:<br>HeaderSearchOptions &headerSearchOptions = theCompInst->getHeaderSearchOpts();<br>headerSearchOptions.AddPath("D:/test/include", clang::frontend::Angled, false, false, false);<br><br>should do it.<br>
<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
I'm writing a tools (do some static check) using clang lib . This is my code:<br>
<br>
void main()<br>
{<br>
    DiagnosticOptions diagnosticOptions;<br>
    TextDiagnosticPrinter *printer = new<br>
TextDiagnosticPrinter(llvm::nulls(),<br>
        diagnosticOptions);<br>
    llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs> diagIDs;<br>
    DiagnosticsEngine diagnostics(diagIDs, printer);<br>
    LangOptions langOpts;<br>
<br>
    TargetOptions targetOpts;<br>
    targetOpts.Triple = llvm::sys::getDefaultTargetTriple();<br>
    TargetInfo *pti = TargetInfo::CreateTargetInfo(diagnostics, targetOpts);<br>
    FileSystemOptions fsopts;<br>
    FileManager fileManager(fsopts);<br>
    SourceManager sourceManager(diagnostics, fileManager);<br>
<br>
    HeaderSearch headerSearch(fileManager, diagnostics, langOpts, pti);<br>
<br>
    CompilerInstance *theCompInst = new CompilerInstance();<br>
    theCompInst->setDiagnostics(&diagnostics);<br>
    Preprocessor *pp = new Preprocessor(diagnostics, langOpts,<br>
pti,sourceManager, headerSearch, *theCompInst);<br>
<br>
    const FileEntry *pFile = fileManager.getFile(file_name);<br>
    sourceManager.createMainFileID(pFile);<br>
<br>
theCompInst->getDiagnosticClient().BeginSourceFile(theCompInst->getLangOpts(),pp);<br>
    theCompInst->setPreprocessor(pp);<br>
    theCompInst->setSourceManager(&sourceManager);<br>
    theCompInst->setTarget(pti);<br>
    theCompInst->setDiagnostics(&diagnostics);<br>
    SourceManager &sourceMgr = theCompInst->getSourceManager();<br>
    theCompInst->createASTContext();<br>
    Rewriter rewriter;<br>
    rewriter.setSourceMgr(sourceMgr,langOpts);<br>
<br>
<br>
    MyASTConsumer consumer(rewriter);<br>
    ParseAST(theCompInst->getPreprocessor(), &consumer,<br>
theCompInst->getASTContext());<br>
    theCompInst->getDiagnosticClient().EndSourceFile();<br>
}<br>
<br>
I want to check some C/C++ code using this tools. But *.h file and *.c file<br>
is not in the same filefold.<br>
<br>
Example:<br>
  test.c context:<br>
    #include "test.h"<br>
     .........<br>
<br>
test.c in D:\test\test.c<br>
test.h in D:\test\include\test.h<br>
<br>
So I need to add "D:\test\include" to the header search path. How to do that<br>
in my code?<br>
Thanks all!<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://clang-developers.42468.n3.nabble.com/How-to-add-custom-include-dir-to-the-header-search-path-tp4031389.html" target="_blank">http://clang-developers.42468.n3.nabble.com/How-to-add-custom-include-dir-to-the-header-search-path-tp4031389.html</a><br>

Sent from the Clang Developers mailing list archive at Nabble.com.<br>
<br></blockquote></div>