Subject: Re: top
To: None <current-users@NetBSD.ORG>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: current-users
Date: 07/16/1998 14:37:55
> #ifdef UVM
>   [vs]
> #if UVM == yes

> Hmm.  I just double checked the syntax with K&R2 and although the
> latter is correct according to them, a small test program seems to
> make that statement true no matter what the value of UVM or even if
> it is defined or not.  I must be missing something.

Well, it shouldn't be quite that bad.

I just did a few tests.  Given the following program

	#include <stdio.h>
	int main(void){
	#if UVM == yes
	printf("UVM == yes\n");
	printf("UVM != yes\n");

I compiled this (cc -o z z.c) with various -D options.  The results
were consistent with what I expected: expand both "UVM" and "yes" and
if they are equal, the test succeeds - where any symbol that remains
after all cpp macros are expanded is evaluated, for purposes of the
comparison, as if it were defined with value 0.

The tests I ran:

no -D options -> equal
-DUVM -> unequal (UVM gets defined as 1)
-DUVM=0 -> equal
-DUVM=yes -> equal
-DUVM=42 -> unequal
-DUVM=42 -Dyes=42 -> equal

Now, this may or may not have anything to do with putting UVM=yes or
UVM=1 in /etc/mk.conf.  Makefile variable definitions are not the same
thing as C preprocessor definitions, not at all.  I don't know what's
going on with /etc/mk.conf; that's why I've remained silent - but I saw
something here that I thought I could explain, the "#if UVM == yes"

					der Mouse

		     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B