hex*_*ter 3 c xcode header-files redefinition
我的c头文件在Xcode中有以下错误消息
Redefinition of 'entry'
Run Code Online (Sandbox Code Playgroud)
但是当我gcc在命令行中使用它编译它时,它工作得很好.你们中的任何人都可以解释原因吗?
这是snapshot.h:
#ifndef SNAPSHOT_H
#define SNAPSHOT_H
#define MAX_KEY_LENGTH 16
#define MAX_LINE_LENGTH 1024
typedef struct value value;
typedef struct entry entry;
typedef struct snapshot snapshot;
struct value {
value* prev;
value* next;
int value;
};
// the line below is where the redefinition error appears
struct entry {
entry* prev;
entry* next;
value* values;
char key[MAX_KEY_LENGTH];
};
struct snapshot {
snapshot* prev;
snapshot* next;
entry* entries;
int id;
};
#endif
Run Code Online (Sandbox Code Playgroud)
这是snapshot.c:
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include "snapshot.h"
int
main(int argc, char *argv[]){
int x = 7;
printf("x= %d\n" , x);
printf("value = %d\n", 1);
return 0;
}
Run Code Online (Sandbox Code Playgroud)