What does the compiler do? I mean if you include iostream it includes other #include. What if you included a header file already included in one of you earlier #include? The compiler replaces them right, but does the compiler detect and if so, avoid replacing repeating #includes?
The preprocessor doesn't care if you already included a header and it just replaces #include as usual.
When writing a header is good practice putting header guards:
1 2 3 4 5
//MyHeader.h
#ifndef MY_HEADER
#define MY_HEADER
// Code here
#endif
This prevents the code to be replaced multiple times
Those headers aren't guarded and there's an infinitely recursive inclusion error. The preprocessor is not smart enough to realize when a header is being included more than once in the same recursion branch.
In Bazzy's example, MY_HEADER is not a placeholder for an actual header. It's a macro the preprocessor defines and it's meant to be used in your headers. The language headers are already guarded, so including them twice does nothing.
Ok, it's still not too clear to me but im just beginning and I was just forward-skimming the book im reading. I'll probably understand more after I read about it. thanks Bazzy and helios! And Grey Wolf!