Quote:Original post by ToohrVykQuote:Original post by DigitalDelusion
Oh, and about speed, modern compilers are smart enough to not reread headers included multiple times rendering use of "hacks" like #pragma once needless to.
Is this really a good thing? Consider the following situation:
<following situation>
A "smart" compiler that ignores duplicate includes will display "1", a standards-respecting compiler would display "2.00000".
I think I read somewhere that some compilers* actually store some form of parse tree from the header, so they can correctly handle multiple includes of the same file with different #defined tokens but still avoid re-parsing the file each time. So the difference in speed between #pragma once and inclusion guards could typically be measured in clock ticks, whereas the difference between re-reading the file for the above situation and re-processing the parse tree is much more significant.
Enigma
*I think this was an article refering to gcc. Of course that could be obsolete information, bad information or plans for a future implementation, I don't recall the article well enough to be sure.