Boost logo

Boost-Build :

From: Joao Abecasis (jpabecasis_at_[hidden])
Date: 2004-12-01 19:04:35


Rene Rivera wrote:
> Joao Abecasis wrote:

[snip]

>> I was looking for something like the preprocessor's defined. I want to
>> check wether a variable is defined or not. The actual value of the
>> variable is not important but I'd like an empty value to be treated as
>> defined.
>
>
> Not possible, Jam makes no distinction between empty and not yet used
> variables. If you evaluate a variable that is not defined it returns
> empty, not some undefined special value.
>
>> Here's what I've learned so far:

[snip]

>> - The ?= operator distinguishes the two, a variable with an empty
>> value is not redefined with it.
>
>
> No. ?= will set the value when the variable is empty. If the variable
> has never been used it's defined and set to empty, then set with the
> value. ?= is equivalent to:
>
> if ! $(VAR) { VAR = $(VALUE) ; } else { VAR = $(VAR) ; }

That's strange... I've written a small test case that is able to
distinguish undefined from defined empty and non-empty variables.

On my system, the attached Jamfile correctly detects the state of
SOME_VARIABLE:

sh# bjam
SOME_VARIABLE was undefined. Well, not anymore...
...found 8 targets...

sh# SOME_VARIABLE= bjam
SOME_VARIABLE has an empty value.
...found 8 targets...

sh# SOME_VARIABLE=value bjam
SOME_VARIABLE is defined as 'value'.
...found 8 targets...

If this is not expected, is it considered a bug (and so I should not
depend on that behaviour)?

> You could use the more modern #if variable, if you set it to some false
> value.

Yes, I can also try that.

Thanks for your help so far!

Best regards,

João Abecasis

 


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk