Does it have issues compiling? Having files that do that isn't the best coding style, but all the ifndef/define in the front of the header prevents infinite loops from occuring, and at that point its more a matter of what's actually defined in each file.
Does it have issues compiling? Having files that do that isn't the best coding style, but all the ifndef/define in the front of the header prevents infinite loops from occuring, and at that point its more a matter of what's actually defined in each file.
If there is conditional statement to decide whether to load the file then it will not be an issue anymore. Problem is that both files do not contains any such construct to prevent such looping. If you study the image you'll see.
It does not appear to have issues to the compiler but that could be because the "#include" directive would only expands to a certain level deep say 8 or 16 so I think it just keeps on loading the same file into the memory as instructed.
There is conditional to check for recursion - the #ifndef, #define "sentinel" at the front of the header file causes the a include file to be opened - and if it's already been included the entire header file gets truncated by the preprocessor.
There is conditional to check for recursion - the #ifndef, #define "sentinel" at the front of the header file causes the a include file to be opened - and if it's already been included the entire header file gets truncated by the preprocessor.
Owing to my limited experience towards header files I failed to realised that the remaining body of the file that follows the "#ifndef" directive is actually inside a conditional, with the scope extends to the #endif at the very end, so the recursive looping will not occur as I thought it would.
It's just one of those things that they just teach you to type in without fully explaining things. Most compiler should have some "preprocess only" option that will halt the compiler immediately after running the preprocessor. It's a pretty educational experience tracing through the include files and seeing what the compiler actually sees.