简体   繁体   中英

Including files in a VS2010 project

Suppose I have a C++ project in Visual Studio 2010 in Windows 7 with the following structure:

ProjectFolder
|
|_FirstFolder
|   some_header.h
|
|_SecondFolder
    main.cpp

In order to include the some_header.h into main.cpp I have to write #include <../FirstFolder/some_header.h> in the that source file.

It is rather cumbersome to use the UNIX directory shortcuts like . and .. and some standards like this one even prohibit to do this. Can I somehow live without the UNIX shortcuts? I would like to directly include files starting the navigation from the project folder like this #include <FirstFolder/some_header.h> , but this does not seem to work.

尝试将项目的主目录添加为其他包含目录(Project-> Properties-> C / C ++-> General-> Additional Include Directories),我认为这应该可行。

You can use

Additional Include Directories

Which can be found via Properties (of a build target) -> Configuration Properties -> C/C++ .

There you can just add the relative path to FirstFolder , relative to the project root. Having done this, #include <some_header.h> would work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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