Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
09/30/04 18:48
Read: times


 
#78448 - RE: C Programming Question
Responding to: ???'s previous message
It's often not quite certain how and where the include files are included - sometimes the include tree is quite long and hard to trace. Like, if you have #include "timeoff.h" in home.c and the two: #include "timeoff.h" and #include "home.c" in main.c, there will be a series of "xxx already defined" or similar errors. A common and really good method for avoiding this type of problems is a simple structure that prevents any header file from being included twice. You do it by writing your file like this:
(say, the file is "timeoff.h")

[start of file]
#ifndef TIMEOFFH
#define TIMEOFFH

[contents of the file here]

#endif
[end of file]

This way after first time #include the TIMEOFFH definition is set and the contents are processed, and so if it's called again, the #ifndef will jump to the end of the file, preventing processing it again.

This may or may not be your problem, but sorry, to information "I get an error" we can only reliably answer "Apply some solution."

List of 11 messages in thread
TopicAuthorDate
C Programming Question            01/01/70 00:00      
   RE: C Programming Question            01/01/70 00:00      
   What error??            01/01/70 00:00      
   Preprocessor            01/01/70 00:00      
   RE: guessing            01/01/70 00:00      
   RE: C Programming Question            01/01/70 00:00      
      RE: C Programming Question            01/01/70 00:00      
         You have a Problem!            01/01/70 00:00      
            RE: You have a Problem!            01/01/70 00:00      
               RE: You have a Problem!            01/01/70 00:00      
   RE: C Programming Question            01/01/70 00:00      

Back to Subject List