C++ 将问题包含在其他文件中?(提升包括)
C++ Include problems in a different file? (Boost include)
所以我正在使用一个在里面使用 Boost 的库LibA
。我有以下结构:
Class1.h:
#ifndef CLASS1_H
#define CLASS1_H
#include <LibA/major.hpp>
#include <other-useful-libraries.h>
namespace LIB{
class HelperClass{
...
};
}
#endif
Class1.cpp
#include <Class1.h>
...Implement Class1...
这两个文件编译成功。但是,我还有另一门课:
Class2.h
#ifndef CLASS2_H
#define CLASS2_H
#include <Class1.h>
#include <other-useful-libraries.h>
namespace LIB{
class MainClass{
...
};
}
#endif
Class2.cpp
#include<Class2.h>
..Implement Class2...
但是,一旦我编译了它,我就会从 Class2 中抛出大量 Boost 错误.cpp主要是未在 boost 中声明的变量、指令问题、一堆error: expected '}' before end of line
以及许多其他仅指向包含中的某些问题的错误。我在这里做错了什么吗?
我知道这些错误非常抽象,但以防万一有人在将来的某个时候遇到这个问题。错误是由于包含的顺序。我将 #include 放在包含的最顶部,并编译了文件。Boost 似乎在包含(带有包含保护(的排序方面存在错误,因此请确保它在顶部。
相关文章:
- 在单元测试项目中包括 .c 文件,并从多个 cpp 文件访问它而不会出现链接问题
- C++包括文件
- 用libclang解析源文件 - 链接问题包括文件
- C 包括文件会导致未知错误
- C++选择文件夹,包括文件
- 在C 中包括文件/模块
- Visual Studio 14.0 和 Windows 工具包中的错误包括文件夹
- 为什么C 标准仍然不包括文件系统和网络
- 循环依赖性包括文件
- 致命错误C1083:无法打开包括文件:'hoa.h':没有这样的文件或目录
- 在C++的应用程序中包括文件(dll,txt等.exe
- SystemC - 测量并在系统C仿真中包括文件解析时间
- C++包括 C 文件(找不到 typedef)
- 包括文件冲突解决方案
- Visual Studio中的嵌套文件夹结构-包括文件
- 包括H文件在其他程序x
- 包括.h文件2类
- 如何处理指针截断在ATLMFC包括文件
- C++包括".h"文件,功能重复混淆
- +头文件,包括文件在定义块或只是在文件的顶部