Quote: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.
That would actually be very, very stupid of a compiler.
Try this:
//Test.h#ifdef MYDEFINEvoid DoSomething(){}#elsevoid DoSomethingElse(){}#endif//main.h#include "Test.h"#define MYDEFINE#include "Test.h"int main(){ DoSomething(); DoSomethingElse();}
Notice that the two places I include will produce different code. Why would I want to do this? Check out
boost::preprocessor for using this multiple including of the same file to great effect.
You can also try including a file twice in your favorite compiler and observe the errors that occur.
Edit: Seems ToohrVyk and I were thinking the same thing, I just took longer to type the message. ;)
----Erzengel des Lichtes光の大天使Archangel of LightEverything has a use. You must know that use, and when to properly use the effects.♀≈♂?