我有 test.h
文件和 example.h
文件,我想将每个文件包含在另一个文件中
我尝试了以下但没有成功。
在文件test.h中:
#ifndef "example.h"
#define "example.h"`
...
#endif
在文件 example.h 中:
#include "test.h"
后来尝试了:
#ifndef "test.h"
#define "test.h"
...
#endif
但没有任何效果。
最佳答案
您需要为每个包含守卫提供一些唯一标识符。例如:
#ifndef EXAMPLE_H
#define EXAMPLE_H
...
#endif
您不能只使用带有#ifndef 等的文件名。
关于c++ - 包括文件问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5444860/