#if !defined
#ifndef
#endif
what does these two do
#if !defined
#ifndef
#endif
what does these two do
Last edited by Zahl; 11-12-2002 at 09:01 AM.
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
that is what is called an inclusion guard. it forces headers to only be included once, so you arent re-defining things that have already been defined. i just recently learned how to use those myself, and they come in handy when you have a large project with multiple files.Code:#ifndef something #define something //.. #endif
say you have a 'main' header file, and you have a few 'sub-' header files, and then your main cpp file. if you include your main header file in your sub-header files, and then include both your main and sub header files in your main cpp file, then you are including your main header file twice which is unnecessary. inclusion guards prevent you from accidentally doing it (or rather, allow you to accidentally do it and not cause any problems).
I came up with a cool phrase to put down here, but i forgot it...
Okay but now we are on the subject what is #pragma and though I know what "#define GOD 15" do I don't know what "#define SoegH" could possible do.
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
answer
I hope this helps!
cj
"Be formless, shapeless, like water... You put water into a cup, it becomes the cup, you put water into a bottle, it becomes the bottle, you put it in a teapot, it becomes the teapot... Now water can flow, or it can crash, be water my friend."
-Bruce Lee
That is quite a bit to go through so if there is a simple ansver...
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
anytime you see:
its saying every time you see the first something, replace it with the something else. you know that, as youve stated.Code:#define (something) (something else)
whenever you see just:
you are just telling the compiler not to freak out whenever it sees the 'something'Code:#define (something)
if you use a:
then you arent really accomplishing anything, code-wise. the something that you defined is never used as a macro, nor does it need to be. the actual function of that is to prevent from using that code more than once.Code:#ifndef (something) #define (something) //... #endif
the first time the program runs into that bit of code it says "have i defined this yet? no? ok then, its defined now." and it actually defines it with all of the code in between that and the #endif.
then, when you try to include that code again later, it says "have i defined this yet? yes? ok then, im skipping down to the #endif." thus saving you from having the program say "hey wait a minute! i already defined these variables/functions. i cant do it again!"
(by the way, if you actually hear your program talking to you, it means its time for a break)
Last edited by ...; 11-12-2002 at 11:54 AM.
I came up with a cool phrase to put down here, but i forgot it...
#pragma sets compiler specific conditions. you are going to need to look at your compiler documentation to know what arguments there are and their uses.
I came up with a cool phrase to put down here, but i forgot it...
hehe... a talking compiler. Long live the future!
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