Re: Macro question regarding single quotes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Aug 15, 2008 at 10:38 PM, Richard Harvey Chapman
<hchapman-gcc-help@xxxxxxxx> 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!

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux