[openbeos] Build System: WARNINGS and DEBUG Variables

  • From: Ingo Weinhold <bonefish@xxxxxxxxxxxxxxx>
  • To: OBOS <openbeos@xxxxxxxxxxxxx>
  • Date: Wed, 27 Aug 2003 01:18:06 +0200

Howdy,

please note, that I just changed the semantics of the WARNINGS and DEBUG 
variables in our build system a bit. Both are now variables that always 
have a value, that is e.g. given an `if $(DEBUG) {...} else {...}' 
statement now always the `if' branch will be executed.

Valid values for the variables are `0' meaning `disabled' and in theory any 
other value for `enabled'. In practice you should specify `1', if you want 
to enable the respective feature and check against `0' to learn whether or 
not it is enabled, in order to avoid conflicts with later extensions. I 
adjusted all Jamfiles that made/make use of the variables accordingly.

A further change concerns the default value for WARNINGS. As you certainly 
know, jam imports all variables from the environment of the process (i.e. 
those variables defined in the shell). So before my change, when the 
variable WARNINGS was not defined in the shell (e.g. by `export WARNINGS=1' 
or running jam like `WARNINGS=1 jam ...') the variable was undefined in jam 
too, which meant, that warnings were disabled. Now, when undefined, 
WARNINGS is set to `1', i.e. warnings are enabled. In other words, now 
warnings have to be explicitly disabled (e.g. by running `WARNINGS=0 jam 
...').

Currently quite a bit of our code doesn't compile without making the 
compiler emit warnings (when enabled, of course). Since warnings are 
usually helpful, from time to time even revealing bugs you would have 
wasted hours of debugging to find them, I think, it is a sensible thing to 
enable them by default. If you work on code, please fix all warnings the 
compiler finds in it (also a thing like `comparison of signed and 
unsigned', which often is harmless -- take a second to check if it really 
is and add an explicit cast (usually from unsigned to signed, unless the 
number might be to great for signed) in this case).

On a related sidenote: Due to a GCC bug, the very helpful warnings for 
missing return statements are only emitted, when optimization is -O0 (or 
IIRC -O3, whose use is discouraged). Since our default optimization level 
is -O2, you won't have this warning by default. So make sure you run 
`OPTIM=-O0 jam ...' from time to time or enable debugging, which as a side 
effect sets optimization to -O0.

Debugging is still disabled by default. If you enable it, the C 
preprocessor macro DEBUG will be defined (and set to the value of the jam 
variable, i.e. `1' for now) when code is compiled. If disabled, the macro 
won't be defined at all. So, you don't have to do something like that in 
the Jamfile for your piece of code (some Jamfiles did).

CU, Ingo

Other related posts: