Deutsch English Français Italiano |
<uv5cov$q401$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!weretis.net!feeder6.news.weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: James Kuyper <jameskuyper@alumni.caltech.edu> Newsgroups: comp.lang.c Subject: Re: Help requested with P99-based macro to create Wayland listeners Date: Wed, 10 Apr 2024 02:49:03 -0400 Organization: A noiseless patient Spider Lines: 29 Message-ID: <uv5cov$q401$1@dont-email.me> References: <pan$3770d$7f0531e6$76520fa1$2c09330e@invalid.invalid> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Wed, 10 Apr 2024 06:49:04 +0200 (CEST) Injection-Info: dont-email.me; posting-host="f3750c68072f1d140c67c0700c16d53d"; logging-data="856065"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19xs0R+K1vqBlbM7S8lPTDurArQ6KusEd0=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:+huJ0XMDFndJ8NxINw7IBUuV9rY= Content-Language: en-US In-Reply-To: <pan$3770d$7f0531e6$76520fa1$2c09330e@invalid.invalid> Bytes: 2508 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().