--- Earl Brannigan earl.brannigan@lindenhouse.co.uk wrote:
--__--__--
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.
Tried this, it didn't work, it transfered the errors to the linker not the compiler.
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.
R, where should the #ifndef bit go then? in which files?
Thanks
D
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
alug, the Anglian Linux User Group list Send list replies to alug@stu.uea.ac.uk http://www.anglian.lug.org.uk/ http://rabbit.stu.uea.ac.uk/cgi-bin/listinfo/alug See the website for instructions on digest or unsub!
===== -------------------- "We all know Linux is great... it does infinite loops in 5 seconds." Linus Torvalds
__________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/