--__--__--
Hi Dave,
Subject: [Alug] More C coding Woes
I have some code which when compiled gives this error
In file included from file1.c:4, from file2.c:6: llist.h:14: redefinition of `Node_ptr' llist.h:14: `Node_ptr' previously declared here llist.h:17: redefinition of `struct Node`
First thing Could be including the same file twice within the same run (pre-compiler directives should prevent this) At the top of the file llist.h is there a directive similar to : #ifndef LLIST_H #define LLIST_H
if there isn't add one. At the bottom of the file you will also need a directive : #endif to close it off.
This also works nicely around the include directives themselves, can spped things up on large projects since the preprocessor doesnt need to open the file and parse it before 'realising' that the file has already been installed. #ifndef FILE_H #include <file.h> #endif will protect it at the point of inclusion. HTH
Can anyone explain what I am doing wrong. I know its something todo with #includes and where they are in which files etc...
Thanks
D