From: Richard Harvey Chapman <hchapman-gcc-help@3gfp.com>
To: gcc <gcc-help@gcc.gnu.org>
Subject: Re: Macro question regarding single quotes
Date: Thu, 21 Aug 2008 13:43:00 -0000 [thread overview]
Message-ID: <48AD6EFE.6020205@3gfp.com> (raw)
In-Reply-To: <b39469680808210610r3c08c417ufd74d40d749ee7a7@mail.gmail.com>
Perfect! And so simple.
Thanks,
H.
Bernd Jendrissek wrote:
> On Fri, Aug 15, 2008 at 10:38 PM, Richard Harvey Chapman
> <hchapman-gcc-help@3gfp.com> wrote:
>> I'd like to shorten-up so redundant code in a switch statement by using a
>> macro for each case. The following code illustrates the problem. In short,
>> is there a way to write the PARSE(a,b) macro that will work in the manner
>> shown below?
>
> How about something like this:
>
> #define rhc__A 'A'
> #define rhc__B 'B'
> #define rhc__C 'C'
> #define rhc__D 'D'
> #define rhc__E 'E'
> #define rhc__F 'F'
> // etc.
>
> // * not allowed in case statement
> #define PARSE(a,b) case (rhc__##a << 8) | rhc__##b: \
> status = Parse##a##b(); \
> break
>
> This depends on a reasonable-sized alphabet, of course!
prev parent reply other threads:[~2008-08-21 13:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-16 11:38 Richard Harvey Chapman
2008-08-21 13:35 ` Bernd Jendrissek
2008-08-21 13:43 ` Richard Harvey Chapman [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48AD6EFE.6020205@3gfp.com \
--to=hchapman-gcc-help@3gfp.com \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).