开发者

Is it possible to trace Xcode C++ compile dependencies?

I'd开发者_运维知识库 like to identify all the include files of a particular file that I chose as a starting point in a C++ project, and then all the include files of those include files and so on until I have everything that I require to compile the file I chose as my starting point.

The background: I am trying to take a file from the 'middle' of a project and 'lift out' just it and all its dependencies. I can do this dependency checking manually but can't see any obvious way to do it automatically in the Xcode IDE.

Any help appreciated!


I'm not aware of any support in Xcode itself for doing this. However, it's not too difficult to do yourself, especially if it's only one file you're interested in.

You can add the -E flag to g++ to have it stop after preprocessing your source file. The preprocessed source file will have comments mentioning all the #included files. Those lines can be extracted with a simple invocation of grep.

Xcode can tell you the full list of arguments it passes to g++ when compiling your files if you go to Build > Build Results, start a build, and click the while oval with lines at the far right of the line saying "Compile somefile.cpp..."

The Doxygen tool has the ability to render graphs of #includes from both source and header files. It's nice, but probably a bit heavyweight for what you're looking to do.


What compiler do you use? If it is MSVC++, then look at usage of options: /P, /EP /P When you use g++, then try cpp utility.

Both ways allows you build file with all includes (name of included files would be included as comments)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜