From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26195 invoked by alias); 21 Aug 2008 13:10:48 -0000 Received: (qmail 26187 invoked by uid 22791); 21 Aug 2008 13:10:48 -0000 X-Spam-Check-By: sourceware.org Received: from an-out-0708.google.com (HELO an-out-0708.google.com) (209.85.132.248) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 21 Aug 2008 13:10:13 +0000 Received: by an-out-0708.google.com with SMTP id c28so157675ana.104 for ; Thu, 21 Aug 2008 06:10:11 -0700 (PDT) Received: by 10.100.3.4 with SMTP id 4mr1784186anc.4.1219324211536; Thu, 21 Aug 2008 06:10:11 -0700 (PDT) Received: by 10.70.66.2 with HTTP; Thu, 21 Aug 2008 06:10:11 -0700 (PDT) Message-ID: Date: Thu, 21 Aug 2008 13:35:00 -0000 From: "Bernd Jendrissek" To: "Richard Harvey Chapman" Subject: Re: Macro question regarding single quotes Cc: gcc-help@gcc.gnu.org In-Reply-To: <48A5E959.6050505@3gfp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <48A5E959.6050505@3gfp.com> X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2008-08/txt/msg00214.txt.bz2 On Fri, Aug 15, 2008 at 10:38 PM, Richard Harvey Chapman 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!