Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED.mailhub.linuxsc.com!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c Subject: Re: Help requested with P99-based macro to create Wayland listeners Date: Wed, 10 Apr 2024 09:03:43 -0700 Organization: A noiseless patient Spider Message-ID: <86plux19y8.fsf@linuxsc.com> References: <86ttka1p61.fsf@linuxsc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: dont-email.me; posting-host="mailhub.linuxsc.com:45.79.96.183"; logging-data="1120477"; mail-complaints-to="abuse@eternal-september.org" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:1GjH+i5LEGofkFXqfJ1Fi/XVWbU= Bytes: 2079 Lines: 32 Blue-Maned_Hawk writes: [request for example] > MAKE_LISTENER(wl_registry, global, global_remove); > > ? > > static const struct wl_registry_listener wl_registry_listener = { > .global = callback_wl_registry_global, > .global_remove = callback_wl_registry_global_remove > }; > > ? > > MAKE_LISTENER(xdg_wm_base, configure, close, configure_bounds, > wm_capabilities); > > ? > > static const struct xdg_wm_base_listener xdg_wm_base_listener = { > .configure = callback_xdg_wm_base_configure, > .close = callback_xdg_wm_base_close, > .configure_bounds = callback_xdg_wm_base_configure_bounds, > .wm_capabilities = callback_xdg_wm_base_wm_capabilities > }; I think it isn't too hard to write a macro to do what you want. I'm pretty sure it's possible to define such a macro using the P99 macros to do the iteration, but I don't see an easy way to do it. If I were in need of such a macro, probably I would ignore the P99 macros and just build a simpler solution that works for the task at hand.