i have 2 files, first_pass.c includes mystring.h describes mystring.c. while testing first_pass.c did following includes
#include "../src/mystring.c" #include "../src/first_pass.c" #include <gtest/gtest.h> everything worked well, until had define structure in mystring.h. simple that
typedef struct split { char *head; char *tail; }split; and started fail while compiling on error: ‘split’ has previous declaration ‘typedef struct split split’
the requirements course using c (not c++) , make, other testing frameworks, check deprecated. understand defines twice struct, first time when loads mystring.c , on first_pass.c. can it?
use header guards prevent inclusion of headers more once.
http://en.wikipedia.org/wiki/include_guard
one suggestion add header files c files not c files c file.
Comments
Post a Comment