BSD variables not declared? (jdk8 & jdk 9 builds)

David Holmes david.holmes at oracle.com
Thu Apr 16 04:49:03 UTC 2015


Hi Kim,

On 16/04/2015 2:26 PM, Kim Barrett wrote:
>> This might be of interest:
>> https://gcc.gnu.org/gcc-4.4/porting_to.html
>> Preprocessor conditionals always evaluated
>
> Also see this:
> http://lists.boost.org/Archives/boost/2011/08/184657.php
>
> —————
> This has come up before. The problem is with code like this:
>
> #if !defined(SOMETHING)
> #elif SOMETHING() == 1
> #endif
>
> In recent versions of gcc it fails when SOMETHING isn't defined
> because the 'SOMETHING() == 1' clause is always evaluated - even
> though the if statement has already been resolved. This is apparently
> compliant with the standard.
>
> The solution is to write:
>
> #if !defined(SOMETHING)
> #else
> # if SOMETHING() == 1
> # endif
> #endif
>
> ——————
>
> That same technique could be applied by us, as an alternative to the proposed changes.
> But it’s pretty annoying ugly, with sometimes long string of trailing #endif lines.

Thanks for all the additional information.

So it seems to me there are two choices here:

a) Use the change proposed but verify that the variables concerned are 
ones that if defined will never be defined to be zero (which I believe 
to be the case but may have trouble proving :( )

b) Replace the 'elif XXX' with 'else ifdef XXX'

For the few cases involved here (b) seems the easier path.

David



More information about the build-dev mailing list