我正在尝试重构和引入一些旧代码,我遇到了这样的事情:
struct foo;
typedef struct foo * foo;
尝试编译它时,出现以下错误:
Source/Types/Types.h:27:18: error: redefinition of 'foo' as different kind of symbol typedef struct foo * foo; ^
有谁知道这是什么原因造成的?我很长时间没有接触过代码,但我当然不记得任何与此相关的错误。它是代码库中一些最核心的代码,一切都取决于它;我不明白我怎么可能错过这样一个明显的错误,如果它确实是一个错误的话。由于原来foo
是一个“结构标签”(struct
关键字后只有一个理智的引用),它怎么会与我的新foo
typedef'd 类型冲突?
编辑1:这是整个实际文件,也许我遗漏了一些东西,但看起来很简单。它会转储大量与上述相同的错误,每种类型都有一个错误:
# if !defined(TYPE_DECLARATIONS)
# define TYPE_DECLARATIONS
# include "Core.h"
# warning "in Core.h"
static int class = 0; // to prove I’m not compiling as C++
struct e(fork);
typedef struct e(fork)* e(fork);
struct e(execution);
typedef struct e(execution)* e(execution);
struct e(thing);
typedef struct e(thing) e(thing);
struct e(typeRepresentation);
typedef struct e(typeRepresentation)* e(typeRepresentation);
struct e(typeRepresentation) {
void * family;
char name[64]; };
struct e(thing) {
void * const pointer;
e(typeRepresentation) const isa; };
# endif //!defined(TYPE_DECLARATIONS)
(另外,忽略e()
宏;在这种情况下它是一个 noop。)