[PATCH xserver 2/3] Use #ifdef instead of #if for features to make Meson easier.

Aaron Plattner aplattner at nvidia.com
Wed Apr 26 18:55:09 UTC 2017


On 04/26/2017 11:21 AM, Eric Anholt wrote:
> Aaron Plattner <aplattner at nvidia.com> writes:
> 
>> We try to do exactly the opposite in our internal driver build, because
>> it's too easy to accidentally do something like
>>
>> #ifdef GLAMOUR_HAS_GBM
>>
>> And mistakes like that don't always cause obvious build failures like
>> this would. So we build everything with -Wundef -Werror=undef and try to
>> use #if whenever possible. It's a shame that Meson makes that hard.
> 
> Meson makes what you want easy with:
> 
>     set10(varname, boolean_value) is the same as above but the value is
>     either true or false and will be written as 1 or 0, respectively
> 
> but autotools usually produces either #define 1 or #undef, unless you go
> through contortions.  This seemed like the easy, consistent solution
> today, given that our codebase is almost all #ifdef.  One alternative
> would be to just disable -Wundef for now.  The other alternative to this
> patch would be something like:
> 
>     conf_array += ['HAVE_DBM_H', cc.has_header('dbm.h')]
> 
> then finish with something like:
> 
>     foreach conf: conf_array
>         if conf[1]
>             conf_data.set(conf[0], '1')
>         endif
>     endforeach
> 
> but I think I'd rather wait and consistently swap to .set10() and #if
> once we've nuked autotools.

Waiting until autotools is nuked sounds fine to me. I just wanted to
throw the idea of using -Wundef out there.

-- Aaron


More information about the xorg-devel mailing list