Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | BartC <bc@freeuk.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Sum using variadic macros |
| Date | 2016-12-14 19:20 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <o2s5vd$k2d$1@dont-email.me> (permalink) |
| References | <03e6722a-248a-46e2-b06d-d1e84e471463@googlegroups.com> <871sxa919h.fsf@bsb.me.uk> <o2rfjg$vi$1@dont-email.me> <e2a70b5a-462d-4510-b994-b2dd4a77c46a@googlegroups.com> |
On 14/12/2016 16:05, Thiago Adams wrote:
> On Wednesday, December 14, 2016 at 10:58:50 AM UTC-2, David Brown wrote:
>> For this sort of thing, I usually make a short custom pre-processor.
>> It's easy to make a little Python script (or whatever language you
>> prefer) that finds instances of HASH("this") and generates an include
>> file that defines an enum with constants of the form "hash_this". Your
>> C code just includes this generated file, and has a macro definition of
>> HASH that expands to the enum tag.
>>
>> At the risk of heresy, constexpr has made this sort of thing vastly
>> easier in C++.
>
> Yes, I agree.
> This is not so important, I can put the computed number instead of the macro.
> I would use macro only if it was easy and clear.
Why can't you calculate it at runtime during initialisation? Or does it
have to be used in array bound or switch-case expressions?
--
Bartc
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Sum using variadic macros Thiago Adams <thiago.adams@gmail.com> - 2016-12-14 02:54 -0800
Re: Sum using variadic macros Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-14 11:51 +0000
Re: Sum using variadic macros David Brown <david.brown@hesbynett.no> - 2016-12-14 13:58 +0100
Re: Sum using variadic macros Richard Heathfield <rjh@cpax.org.uk> - 2016-12-14 14:01 +0000
Re: Sum using variadic macros Thiago Adams <thiago.adams@gmail.com> - 2016-12-14 08:05 -0800
Re: Sum using variadic macros BartC <bc@freeuk.com> - 2016-12-14 19:20 +0000
Re: Sum using variadic macros Thiago Adams <thiago.adams@gmail.com> - 2016-12-14 11:26 -0800
Re: Sum using variadic macros BartC <bc@freeuk.com> - 2016-12-14 20:06 +0000
Re: Sum using variadic macros Thiago Adams <thiago.adams@gmail.com> - 2016-12-14 05:25 -0800
Re: Sum using variadic macros mark.bluemel@gmail.com - 2016-12-14 08:10 -0800
Re: Sum using variadic macros Thiago Adams <thiago.adams@gmail.com> - 2016-12-14 08:23 -0800
Re: Sum using variadic macros Malcolm McLean <malcolm.mclean5@btinternet.com> - 2016-12-14 11:32 -0800
Re: Sum using variadic macros Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-14 16:26 +0000
Re: Sum using variadic macros David Brown <david.brown@hesbynett.no> - 2016-12-14 19:09 +0100
Re: Sum using variadic macros supercat@casperkitty.com - 2016-12-14 11:33 -0800
Re: Sum using variadic macros Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-14 19:40 +0000
csiph-web