Is there a pragma directive for include directories?
As the title says: Is there a pragma directive for include directories using VS20** C++? I think about something like:
#pragma comment(include, "..\externals\blah\includes\")
So that I can use includes in this style, and blah.h also can use this style inside?
#include <blah.h>
I know that I can set include directories in my project settings,开发者_如何学编程 but I am asking for a preprocessor directive, because else i would have to set it for every compiler profile.
Regards Nem
you can create a txt file (ex. IncludeDirs.txt). Inside that file you can add the include folders:
/I "."
/I ".."
/I ".\OtherFolder"
then in the properties->configuration properties->C/C++-> Command line add the following string:
@includedirs.txt
You can create a different file for each profile (Debug, Release, etc.)
I don't think there's any way to do this. include_alias is only useful on a file-by-file basis.
You can create a .props file that contains selected project properties of choice.
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup>
<IncludePath>C:\ExampleDir\Include;$(IncludePath)</IncludePath>
</PropertyGroup>
</Project>
You can move blocks of existing properties from your .vcxproj file(s).
It may also contain per Configuration conditions for properties (this is also something you can learn from insides of a .vcxproj file).
Important:
The .props file needs to be referenced from the Property Manager tab
[View] - [Property Manager] menu - select [Add Existing Property Sheet...]
while focusing a specific build configuration.
These property files are well reusable between different projects. Combined with Environment Variable values (e.g. use $(MySdkPath) instead of direct "C:\MySdk") this approach provides a good and universal solution.
I am not aware of any.
A while ago I solved this problem by making "all" and "all.cpp" files in every directory to include each header and source file in it. It needs some manual work to create and maintain but I believe it is worth it. This way I can just write something like #include <Frigo/Math/all>
. It might be even possible to create a script that updates them automatically.
You could add a "master folder" to your project properties and then put the right folder in the include directive, for example:
folder "includes" with subfolders "Unicode"/"ASCII", both with a header-file named "String.h" (you shouldn't use the same name)
in code use:
#ifdef UNICODE // or your preprocessor flag
# include <Unicode/string.h>
#else
# include <ASCII/string.h>
#endif
you also can use DEBUG or any keyword, as long as you specify it in Project-Settings --> C/C++ --> Preprocessor --> Preprocessor defintions
I am coming too late, but I tried
#define path_include <C:/foo_folder/##a>
and then
#include path_include(blah.h)
#include path_include(bluh.h)
It works.
精彩评论