Preprocessor directives checking

For code related discussions and questions
Post Reply
CesarIII
New user
Posts: 5
Joined: 15 Dec 2014, 00:02

Preprocessor directives checking

Post 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.
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: Preprocessor directives checking

Post 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 (?)
CesarIII
New user
Posts: 5
Joined: 15 Dec 2014, 00:02

Re: Preprocessor directives checking

Post 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.
User avatar
vexed
Inactive
Inactive
Posts: 2538
Joined: 27 Jul 2010, 02:07

Re: Preprocessor directives checking

Post 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.
/facepalm ...Grinch stole Warzone🙈🙉🙊 contra principia negantem non est disputandum
Super busy, don't expect a timely reply back.
Post Reply