C - redefinition error in Xcode -
my c header file has following error message in xcode
redefinition of 'entry'
but works when compile using gcc
in command line. of give explanation of why?
this 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; }; // line below 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
this 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; }
entry
reserved keyword , later declared obsolete. older compilers don't allow (see this question). change name of struct , should fine.
Comments
Post a Comment