Bug 90677

Summary: redundant declarations compiler warnings in protocol headers
Product: Wayland Reporter: Arnaud Vrac <rawoul>
Component: waylandAssignee: Wayland bug list <wayland-bugs>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Arnaud Vrac 2015-05-27 13:16:19 UTC
Since commit e799b1fa9c (scanner: add a new --include-core-only option), the compiler outputs warnings in some cases when using the -Wredundant-decls flag.

Generated protocol headers include forward declarations for the protocol interfaces type, and extern declarations for the interfaces implementation. The new code also adds those declarations for interfaces that are defined by another extension. This can lead to redundant declarations.

For example, if we have an extension protocol with the following interface:

<interface name="foo" version="1">
  <request name="bar">
    <arg name="a" type="object" interface="wl_surface"/>
  </request>
</interface>

The foo-client-protocol.h file will declare:

struct wl_surface;
extern const struct wl_interface wl_surface_interface;

which are already declared in wayland-client-protocol.h. So the compiler will output a warning if both headers are included.

Here are solutions thought of on IRC:

 1/ only add the extern declarations in the protocol header for interfaces declared in the xml file, not for interfaces that are from a different extension. This is the old behaviour and only breaks client code that uses requests which create an object from a different extension. This is bad design, and can be easily fixed by including the other extension protocol header first.

 2/ guard each extern declaration with an #ifndef. This will not work when mixing with old headers which do not have the guards.
Comment 1 Pekka Paalanen 2015-06-01 10:03:58 UTC
commit f0be757bfaf8cd43e89471ec7fa8f57093d38f81
Author: Giulio Camuffo <giuliocamuffo@gmail.com>
Date:   Thu May 28 19:30:33 2015 +0300

    scanner: don't emit the extern declarations for external types


Marking as fixed.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.