0

我有这个 cpp 文件,其中包含一堆 C 文件。

主文件

extern "C" {
#include "types.h"
#include "file1.h"
}
...

类型.h

#IFNDEF TYPES_H
#DEFINE TYPES_H
typedef unsigned short int char16;
...
#ENDIF // TYPES_H

文件1.h

#include "file2.h"
...

文件2.h

...
char16* testCode();
...

由于某种原因,编译器给我一个错误,即未声明 char16。知道为什么包含不会从 CPP 文件继承到 C 文件吗?任何帮助表示赞赏。谢谢!

4

1 回答 1

2

您应该在 file2.h 中包含 types.h。你似乎没有这样做。

顺便说一句,发布的代码在我的机器上编译没有任何错误,而如果我"#include "types.h"在 main.cpp 中注释,它会给我一个错误。

于 2012-05-31T14:33:58.870 回答