Page 1 of 1

Preprocessor directives checking

Posted: 20 Dec 2014, 19:59
by CesarIII
This is a very specific question about the game code. More like a doubt actually.
In the case of, for example, the main.cpp file, we can see the following directives all over the code:

Code: Select all

#ifdef DEBUG
    debug() ...
#endif
Wouldn't the following be "equivalent"? Or are we aiming to avoid conditional statements at runtime?:

- At the program head:

Code: Select all

#ifdef DEBUG
    bool debug = true;
#else
    bool debug = false;
#endif
- In the middle of the code:

Code: Select all

if(debug){
   debug() ...
}
It is not like this is important at all. I'm just watching it from the readibility perspective.

Re: Preprocessor directives checking

Posted: 20 Dec 2014, 22:17
by NoQ
debug() already assumes a run-time conditional jump based on enabled_debug[] array lookup. I guess there's not much sense in these #ifdef's. Also, they seem to be activated only in MSVC debug builds (?)

Re: Preprocessor directives checking

Posted: 21 Dec 2014, 02:38
by CesarIII
NoQ wrote:Also, they seem to be activated only in MSVC debug builds (?)
It can be activated by adding -DDEBUG as a compiler option. In the Makefile you can find it here:

Code: Select all

WZ_CPPFLAGS =  ... -DDEBUG ... 
So after you run make outside MSVC or any other IDE, all of them are activated.

Re: Preprocessor directives checking

Posted: 21 Dec 2014, 04:59
by vexed
DEBUG != debug().
What I mean by that is, we have stuff that we want enabled only with DEBUG builds.
debug() is just a poorly named function that is mainly used to communicate specific messages.