[PATCH wayland 2/6] wayland-egl: make wayland-egl-backend.h C++ safe

Emil Velikov emil.l.velikov at gmail.com
Fri Feb 16 10:40:45 UTC 2018


On 15 February 2018 at 23:12, Derek Foreman <derekf at osg.samsung.com> wrote:
> On 2018-02-15 12:50 PM, Emil Velikov wrote:
>>
>> From: Emil Velikov <emil.velikov at collabora.com>
>>
>> private is a reserved keyworkd in C++. Thus to make things work, we
>> should use something else - wl_egl_window::driver_private.
>>
>> Make sure to do so only for C++ contexts, or otherwise it will break the
>> API - leading to build failures when used alongside existing Mesa.
>>
>> Cc: Daniel Stone <daniels at collabora.com>
>> Cc: Arnaud Vrac <rawoul at gmail.com>
>> Cc: Miguel A . Vico <mvicomoya at nvidia.com>
>> Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
>> ---
>>   egl/wayland-egl-backend.h | 8 ++++++++
>>   1 file changed, 8 insertions(+)
>>
>> diff --git a/egl/wayland-egl-backend.h b/egl/wayland-egl-backend.h
>> index 3c23a56..b16ff45 100644
>> --- a/egl/wayland-egl-backend.h
>> +++ b/egl/wayland-egl-backend.h
>> @@ -53,7 +53,15 @@ struct wl_egl_window {
>>         int attached_width;
>>         int attached_height;
>>   +     /*
>> +        * private is a reserved word in C++ - use driver_private instead.
>> +        * Don't change the name otherwise, in order to preserve the
>> existing C API.
>> +        */
>> +#ifdef __cplusplus
>> +       void *driver_private;
>> +#else
>>         void *private;
>> +#endif
>
>
> Maybe it's just me, but having different names for the same variable for C
> vs C++ compilation seems really nasty and potentially surprising.
>
Indeed it is surprising. In practise nobody should be using C++.
The guards are added just for lolz - but we can flip things the other
way around.
Namely, error out when using C++ ;-)

> Shouldn't old versions of Mesa already have internal versions of this header
> anyway?  I didn't think it was publicly installed until now...
>
That's what Dan't patch did. Sadly as-is (before this series) every
Mesa release under the sun - released or git will fail to build.
I don't think we can retroactively go and fix the all :-(

-Emil


More information about the wayland-devel mailing list