what does these two do
what does these two do
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:
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).
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.
I hope this helps!
That is quite a bit to go through so if there is a simple ansver...
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:
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:
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)
#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.
hehe... a talking compiler. Long live the future! :D