Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #384260

Re: Help requested with P99-based macro to create Wayland listeners

From Tim Rentsch <tr.17687@z991.linuxsc.com>
Newsgroups comp.lang.c
Subject Re: Help requested with P99-based macro to create Wayland listeners
Date 2024-04-10 09:08 -0700
Organization A noiseless patient Spider
Message-ID <86h6g919py.fsf@linuxsc.com> (permalink)
References (2 earlier) <pan$325a1$29dc1a44$271afe6a$307a257b@invalid.invalid> <uv46mg$e1e0$1@dont-email.me> <pan$57aa8$bcee1756$62f53bf3$9223a50a@invalid.invalid> <uv5kpk$s1fr$1@dont-email.me> <87r0fdqnmi.fsf@bsb.me.uk>

Show all headers | View raw


Ben Bacarisse <ben.usenet@bsb.me.uk> writes:

> David Brown <david.brown@hesbynett.no> writes:
>
>> On 09/04/2024 22:20, Blue-Maned_Hawk wrote:
>>
>>> David Brown wrote:
>>>
>>>> On 09/04/2024 20:17, Blue-Maned_Hawk wrote:
>>>>
>>>>> Tim Rentsch wrote:
>>>>>
>>>>>> What is it that you want to accomplish?
>>>>>
>>>>> As i stated in the subject line, i am trying to create a macro to
>>>>> create Wayland listeners.
>>>>
>>>> Assume, for the sake of argument, that no one knows or cares anything
>>>> about Wayland or listeners.
>>>
>>> <https://xkcd.com/1432/>
>>>
>>>> You are trying to use a set macros to expand to some code.  Start by
>>>> showing what code you want to get from examples of using your macros -
>>>> then people can try to help get the macros right.
>>>
>>> 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 };
>>
>> #define _get_6th_arg(_1, _2, _3, _4, _5, _arg, ...) _arg
>> #define _fe_0(_global, _call, ...)
>> #define _fe_1(_global, _call, x) _call(_global, x)
>> #define _fe_2(_global, _call, x, ...) _call(_global, x) _fe_1(_global,
>>  _call, __VA_ARGS__)
>> #define _fe_3(_global, _call, x, ...) _call(_global, x) _fe_2(_global,
>>  _call, __VA_ARGS__)
>> #define _fe_4(_global, _call, x, ...) _call(_global, x) _fe_3(_global,
>>  _call, __VA_ARGS__)
>> #define expand_macro_for_each(_global, _macro, ...) \
>>     _get_6th_arg("ignored", __VA_ARGS__, \
>>     _fe_4, _fe_3, _fe_2, _fe_1, _fe_0)(_global, _macro, __VA_ARGS__)
>>
>>
>> #define MAKE_LISTENER(object_type, ...) _make_listener(object_type,
>>  __VA_ARGS__)
>> #define _listener_entry(_global, _field) , . _field = callback_ ## _global
>> ## _ ## field
>
> s/field/_field/

The bigger problem is that the proposed solution doesn't work
for more than five fields.  Clearly the idea is to define a
macro that works for an unlimited number of fields, or at least
a fairly large number.

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Help requested with P99-based macro to create Wayland listeners Blue-Maned_Hawk <bluemanedhawk@invalid.invalid> - 2024-04-09 00:36 +0000
  Re: Help requested with P99-based macro to create Wayland listeners Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-04-09 09:22 -0700
    Re: Help requested with P99-based macro to create Wayland listeners Blue-Maned_Hawk <bluemanedhawk@invalid.invalid> - 2024-04-09 18:17 +0000
      Re: Help requested with P99-based macro to create Wayland listeners David Brown <david.brown@hesbynett.no> - 2024-04-09 21:59 +0200
        Re: Help requested with P99-based macro to create Wayland listeners Blue-Maned_Hawk <bluemanedhawk@invalid.invalid> - 2024-04-09 20:20 +0000
          Re: Help requested with P99-based macro to create Wayland listeners David Brown <david.brown@hesbynett.no> - 2024-04-10 11:05 +0200
            Re: Help requested with P99-based macro to create Wayland listeners scott@slp53.sl.home (Scott Lurndal) - 2024-04-10 14:26 +0000
              Re: Help requested with P99-based macro to create Wayland listeners David Brown <david.brown@hesbynett.no> - 2024-04-10 16:54 +0200
                Re: Help requested with P99-based macro to create Wayland listeners "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-04-10 11:44 -0700
                Re: Help requested with P99-based macro to create Wayland listeners David Brown <david.brown@hesbynett.no> - 2024-04-10 21:29 +0200
                Re: Help requested with P99-based macro to create Wayland listeners bart <bc@freeuk.com> - 2024-04-10 20:39 +0100
                Re: Help requested with P99-based macro to create Wayland listeners "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-04-10 13:55 -0700
                Re: Help requested with P99-based macro to create Wayland listeners "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-04-10 13:40 -0700
                Re: Help requested with P99-based macro to create Wayland listeners "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-04-10 13:48 -0700
            Re: Help requested with P99-based macro to create Wayland listeners Ben Bacarisse <ben.usenet@bsb.me.uk> - 2024-04-10 15:49 +0100
              Re: Help requested with P99-based macro to create Wayland listeners Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-04-10 09:08 -0700
                Re: Help requested with P99-based macro to create Wayland listeners David Brown <david.brown@hesbynett.no> - 2024-04-10 18:40 +0200
          Re: Help requested with P99-based macro to create Wayland listeners Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-04-10 09:03 -0700
  Re: Help requested with P99-based macro to create Wayland listeners James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-04-10 02:49 -0400
    Re: Help requested with P99-based macro to create Wayland listeners Blue-Maned_Hawk <bluemanedhawk@invalid.invalid> - 2024-04-10 13:57 +0000
    Re: Help requested with P99-based macro to create Wayland listeners Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-04-10 09:05 -0700
    Re: Help requested with P99-based macro to create Wayland listeners Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-04-11 00:57 +0000
  Re: Help requested with P99-based macro to create Wayland listeners Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-04-10 19:56 -0700

csiph-web