I've never used these before, but from time to time when reading other peoples code I stumble upon #ifndef and #pragma. What does these do. they got a be in familly with #define and #include right?
I've never used these before, but from time to time when reading other peoples code I stumble upon #ifndef and #pragma. What does these do. they got a be in familly with #define and #include right?
Well english isn't my first language, (it's instead a useless language called danish which only 5 milion people speak!!) so if you think my grammar SUCKS (it does by the way) than you're more then welcome to correct me.
Hell I might even learn something
#ifndef is most commonly seen with header files, to prevent from the class being #included twice.
i.e.
not sure what #pragma does though.Code:#ifndef CLASS_H #define CLASS_H #endif
Ok, straight from my book.The #pragma directive is a preprocessor. The #pragma directive has no formal definition.Compilers may use it in ways the compiler vender sees fit.Typical uses are to suppress and enable certain annoying warning messages.If the compiler uses the directive this way,you could use the custom #pragma to suppress compiler warning messages you do not wish to read.
Another words, probably need to look at the documentation on your compiler.
#pragma is compiler specific, but here's one example of pragma use, which quiets the compiler up about unsafe boolean testing in macros (I think that's what I used it for) :
which says: disable warning 4804Code:#pragma warning(disable:4804)
and #ifndef is, "if the following is undefined...", compile this piece.
"He who makes a beast of himself, gets rid of the pain of being a man." Dr. Johnson
what about endif then... it's always placed in my code automaticly by my compiler so I really don't know what it does.
BTW can one use define to other things but values like including headers?
Well english isn't my first language, (it's instead a useless language called danish which only 5 milion people speak!!) so if you think my grammar SUCKS (it does by the way) than you're more then welcome to correct me.
Hell I might even learn something
>>what about endif then... it's always placed in my code automaticly by my compiler so I really don't know what it does.
#endif closes an #if block, if you don't use it then the compiler doesn't know where to stop preprocessing :-)
*Cela*