So, I'm trying to build this program that has two source files and one include file. Both source files include the single include file, I know that's why I'm getting the errors. I also know that the supposed solution is to do something like:
My problem is this. I did that, and I still get the errors, I have that kind of block around the entire include file.Code:#ifndef _SOMETHING_ #define _SOMETHING_ //All sorts of whatever code here #endif
What I really want to know, is why this is needed, because I only get these kinds of errors in certain include files. Does it have to do with having functions defined (not just declared) in the include file? Does it have to do with having static variables or functions? If it's one of those two reasons, should I only have the #ifndef, #define, #endif block around the declared functions and/or static variables? Or should I have it around the entire file?
Thanks for the help.