中的递归包含路径

中的递归包含路径

本文介绍了Visual Studio 2015 中的递归包含路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


所以我是使用 Visual Studio 的新手,我正在尝试创建一个项目来编译我现有的程序.该程序已经在 macOS 上使用 Xcode 编译.项目的文件夹结构如下所示:


So I'm new to using Visual Studio and I'm trying to create a project to compile my existing program. The program already is compiling on macOS using Xcode. The folder structure of the project looks like this:

main folder
  src
    some code here
    Debug
      some code here
    Utility
      some code here
      Special Utility Folder
    Rendering
      some code here
      Rendering Utils
...

当我尝试将项目加载到 Visual Studio 时,我收到很多错误消息,说找不到头文件.我做了一些调查,似乎包含路径不是递归的.所以要包含来自 src/Utility 的文件,我必须写

When I tried to load the project up into Visual Studio, I got a lot of errors saying that the header files could not be found. I did some investigation and it seems like the include paths are not recursive. So to include a file from src/Utility I would have to write

#include "Utility/header.hpp"

但是项目中的所有代码都使用了include like

But all of the code in the project uses includes like

#include "header.hpp"

有没有办法让它在visual studio中工作?

Is there a way to get this to work in visual studio?

附言手动添加所有文件夹作为它们自己的包含路径工作,但随着项目的增长维护将很痛苦,特别是因为我的大部分工作将在 Xcode 中完成

P.s. manually adding all of the folders as their own include paths works, but it will be a pain to maintain as the project grows, especially since majority of my work will be done in Xcode

推荐答案

您可以在项目属性中设置所有文件夹的包含路径(不是递归的):

You can set the include paths for all the folders(it is not recursive) in the project properties:

访问项目配置:

  1. 右键单击项目,然后选择属性".
  2. 选择配置属性->C/C++->常规.
  3. 在 Additional Include Directories 下设置路径:即:. Debug Utility 等等..
  1. Right-click on the project, and select Properties.
  2. Select Configuration Properties->C/C++->General.
  3. Set the path under Additional Include Directories:i.e.: . Debug Utility etc..

也许您还可以使用 cmd 工具在 txt 文件中创建包含路径(即:IncludePath.txt).在该文件中,您可以添加包含文件夹:

Maybe you can also use a cmd tool to create the includes path in a txt file(i.e.: IncludePath.txt).Inside that file you can add the include folders:

/I "."
/I ".."
/I ".\Debug"
/I ".\Utility"

然后在 Additional Include Directories 下设置路径:

Then set the path under Additional Include Directories:

@IncludePath.txt

这篇关于Visual Studio 2015 中的递归包含路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 12:33