简体   繁体   English

C ++ Visual Studio 2010从项目/构建中排除文件

[英]C++ Visual Studio 2010 Exclude file from project/build

I have a C++ project originally developed under Linux (Eclipse). 我有一个最初在Linux(Eclipse)下开发的C ++项目。 Since I wanted my app to run under Windows as well I extracted the non-portable portion of the code into a separate NonPortable.hpp(cpp) file. 由于我也希望我的应用程序也能在Windows下运行,因此我将代码的不可移植部分提取到了单独的NonPortable.hpp(cpp)文件中。 My plan was to share the code in a Visual Studio project while excluding the Linux non-portable stuff and including the Windows versions. 我的计划是在Visual Studio项目中共享代码,同时排除Linux不可移植的内容和Windows版本。

/I"D:\...\Visual Studio 2010\Projects\PROJECT\include" /I"D:\SHARED FOLDER\include"

The first path contains the Windows version of NonPortable.hpp while the second path contains all other header file (including the Linux version of NonPortable.hpp). 第一个路径包含Windows版本的NonPortable.hpp,而第二个路径包含所有其他头文件(包括Linux版本的NonPortable.hpp)。 Now the problem is that no matter what I do the compiler always includes (also) the Linux version. 现在的问题是,无论我做什么,编译器始终都包括(也包括)Linux版本。 I have tried excluding it from the project/build with no success. 我尝试将其从项目/构建中排除,但未成功。

If some of the other headers include NonPortable.hpp, they will first look for it in their own directory. 如果其他一些头文件包含NonPortable.hpp,则它们将首先在自己的目录中查找它。

I would have put the system dependent code in two separate directories, one for Windows and one for Linux. 我将把与系统有关的代码放在两个单独的目录中,一个用于Windows,一个用于Linux。 Then you can use slightly different include paths on each system, just as you started to do here. 然后,您可以在每个系统上使用稍有不同的包含路径,就像您在此处开始做的那样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM