public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Bernd Jendrissek" <bernd.jendrissek@gmail.com>
To: "Richard Harvey Chapman" <hchapman-gcc-help@3gfp.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: Macro question regarding single quotes
Date: Thu, 21 Aug 2008 13:35:00 -0000	[thread overview]
Message-ID: <b39469680808210610r3c08c417ufd74d40d749ee7a7@mail.gmail.com> (raw)
In-Reply-To: <48A5E959.6050505@3gfp.com>

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!

  reply	other threads:[~2008-08-21 13:10 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 [this message]
2008-08-21 13:43   ` Richard Harvey Chapman

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=b39469680808210610r3c08c417ufd74d40d749ee7a7@mail.gmail.com \
    --to=bernd.jendrissek@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=hchapman-gcc-help@3gfp.com \
    /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).