包括来自不同目录的头文件? [英] including header files from different directories?
本文介绍了包括来自不同目录的头文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在从事一个项目,但我对如何从其他目录导入文件感到困惑.这是我的一些文件的组织方式:
I am working on a project and I keep getting stumped on how I am supposed to import files from a different directory. Here is how some of my files are organized:
-stdafx.h
-core/
-->renderer.cpp
-shapes/
-->sphere.h
-->sphere.cpp
如何从core/renderer.cpp
访问stdafx.h
和shapes/sphere.h
?
推荐答案
有很多方法.例如,您可以#include "../stdafx.h"
.更常见的是将项目的根目录添加到包含路径并使用#include "shapes/sphere.h"
.或在包含路径中有标头的单独目录.
There are many ways. You can #include "../stdafx.h"
, for instance. More common is to add the root of your project to the include path and use #include "shapes/sphere.h"
. Or have a separate directory with headers in include path.
这篇关于包括来自不同目录的头文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文