Clang 工具 (libtooling):将标头搜索路径设置为标准库标头.基础框架

Clang Tool (libtooling): set header search path to standard libs headers. Foundation framework(Clang 工具 (libtooling):将标头搜索路径设置为标准库标头.基础框架)
本文介绍了Clang 工具 (libtooling):将标头搜索路径设置为标准库标头.基础框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

related link http://kevinaboos.wordpress.com/2013/07/23/clang-tutorial-part-ii-libtooling-example

I'am using CommonOptionsParser to parse arguments for clang tool:

// parse the command-line args passed to your code
CommonOptionsParser op(argc, argv);
// create a new Clang Tool instance (a LibTooling environment)
ClangTool Tool(op.getCompilations(), op.getSourcePathList());

// run the Clang Tool, creating a new FrontendAction (explained below)
int result = Tool.run(newFrontendActionFactory<SomeAction>());

and next parameters:

llvm/Debug+Asserts/bin/mytool  /somePath/someSource.mm -- 

When I run my tool (based on clang libtooling) on some source file, tool tries find included files, f.e: #import "SomeClass.h", or #import<Foundation/Foundation.h>

And if it cannot find headers, it generates errors:

fatal error: ‘Foundation/Foundation.h’ file not found.

Could you tell me, if you know, how can I direct tool to the standard frameworks? And How can I direct it to the some header search path? How can I set headers search path when running tool?

解决方案

I've solved the issue. you can add path to framework with options

-Iinclude -Ipath_for_foundation/Headers

after --

llvm/Debug+Asserts/bin/mytool  /somePath/someSource.mm -- -Iinclude -Ipath_for_foundation/Headers

BUT, standard frameworks usually included with name of framework as prefixes

#import <Foundation/Foundation.h>

frameworks sources are placed in the folder called Headers, so clang cannot find them. So, i'am going to find solution for that issue.

UPDATE:

solution

llvm/Debug+Asserts/bin/mytool  /somePath/someSource.mm -- -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk/System/Library/Frameworks/

这篇关于Clang 工具 (libtooling):将标头搜索路径设置为标准库标头.基础框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

C++ Library Include(C++ 库包含)
How can I get the contents of a file at build time into my C++ string?(如何在构建时将文件的内容获取到我的 C++ 字符串中?)
C++ previous definition error(C++以前的定义错误)
Writing or Copying Visual C++ console output to text file(将 Visual C++ 控制台输出写入或复制到文本文件)
C++ class, its base class and circular include includes(C++ 类,它的基类和循环包含包括)
How to see the actual order of include files after preprocessing?(预处理后如何查看包含文件的实际顺序?)