[PATCH wayland] private: Remove unnecessary forward declarations

Pekka Paalanen ppaalanen at gmail.com
Thu May 12 08:43:45 UTC 2016


On Mon, 09 May 2016 13:24:29 -0500
Derek Foreman <derekf at osg.samsung.com> wrote:

> On 07/05/16 09:11 AM, Yong Bakos wrote:
> > From: Yong Bakos <ybakos at humanoriented.com>
> > 
> > Declarations for wl_connection and wl_closure are not needed here.
> > wl_closure already has a complete definition.
> > Removing these forward declarations results in a clean, warning-free compile.
> > 
> > Signed-off-by: Yong Bakos <ybakos at humanoriented.com>
> > ---
> >  src/wayland-private.h | 4 ----
> >  1 file changed, 4 deletions(-)
> > 
> > diff --git a/src/wayland-private.h b/src/wayland-private.h
> > index 994bc45..0d8b630 100644
> > --- a/src/wayland-private.h
> > +++ b/src/wayland-private.h
> > @@ -99,10 +99,6 @@ wl_map_lookup_flags(struct wl_map *map, uint32_t i);
> >  void
> >  wl_map_for_each(struct wl_map *map, wl_iterator_func_t func, void *data);
> >  
> > -struct wl_connection;
> > -struct wl_closure;
> > -struct wl_proxy;  
> 
> Trying to think of a place in C where a forward struct declaration is
> actually required.
> 
> This file isn't it. ;)
> 
> Reviewed-by: Derek Foreman <derekf at osg.samsung.com>

Why are they not required, btw? Yes, I don't get a compiler warning or
anything here and now, but I do recall sometimes seeing warning like
"declared inside parameter list" or such. So declaring in a return type
is fine?

wl_closure indeed is defined before its use, but wl_connection and
wl_proxy are not even declared.

If I move the declaration of wl_connection_destroy before
wl_connection_create, I get this:

In file included from src/connection.c:44:0:
src/wayland-private.h:107:30: warning: ‘struct wl_connection’ declared inside parameter list [enabled by default]
 wl_connection_destroy(struct wl_connection *connection);
                              ^
src/wayland-private.h:107:30: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default]
src/connection.c:195:1: error: conflicting types for ‘wl_connection_destroy’
 wl_connection_destroy(struct wl_connection *connection)
 ^
In file included from src/connection.c:44:0:
src/wayland-private.h:107:1: note: previous declaration of ‘wl_connection_destroy’ was here
 wl_connection_destroy(struct wl_connection *connection);
 ^

Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 811 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20160512/677c521b/attachment.sig>


More information about the wayland-devel mailing list