Sujet : Re: Help requested with P99-based macro to create Wayland listeners
De : jameskuyper (at) *nospam* alumni.caltech.edu (James Kuyper)
Groupes : comp.lang.cDate : 10. Apr 2024, 08:49:03
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <uv5cov$q401$1@dont-email.me>
References : 1
User-Agent : Mozilla Thunderbird
On 4/8/24 20:36, Blue-Maned_Hawk wrote:
This macro doesn't work and i don't know why. I've tried multiple
different things to try to delay the expansion of _0MAKE_LISTENER and none
of them have worked. I don't know if there's a more idiomatic way to do
this. I've tried looking at the output from putting it through ‘cpp’ and
that didn't work because it errored out before i could see what it
expanded to.
#define MAKE_LISTENER(object_type, ...) static const struct\
object_type##_listener object_type##_listener = { P99_SEQ(\
This isn't a C problem, or at least,not entirely a C problem. I'd
thought that the P99 in your subject line might be a typo for C99, but I
have no idea what P99_SEQ is. Wikipedia knows 9 different meanings for
P99. Google gives me way too many hits from P99, I have no idea which
one is relevant. You might need to take this up with someone who has
some idea what P99 is.
The basic technique for delaying expansion is as follows:
#define STR(e) #e
#define STRSTR(e) STR(e)
and then replace WHATEVER with STRSTR(WHATEVER).
There are, I understand, good reasons based upon how macro expansion
works why this solution is necessary, but even when I was a lot younger
I had trouble understanding those reasons. I generally had to rely upon
trial and error to figure out the right way to use STRSTR().