From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25962 invoked by alias); 21 Aug 2008 13:35:40 -0000 Received: (qmail 25943 invoked by uid 22791); 21 Aug 2008 13:35:39 -0000 X-Spam-Check-By: sourceware.org Received: from perm68-235.ij.net (HELO smirk.3gfp.com) (209.216.68.235) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 21 Aug 2008 13:35:00 +0000 Received: from localhost (localhost [127.0.0.1]) by smirk.3gfp.com (Postfix) with ESMTP id 6B03A9B2BD7 for ; Thu, 21 Aug 2008 09:34:58 -0400 (EDT) Received: from smirk.3gfp.com ([127.0.0.1]) by localhost (smirk.3gfp.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id jkwk8dw07Ypu for ; Thu, 21 Aug 2008 09:34:55 -0400 (EDT) Received: from harveybook.swlocal (sw.contech.com [64.132.158.194]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smirk.3gfp.com (Postfix) with ESMTP id B0E329B2F40 for ; Thu, 21 Aug 2008 09:34:55 -0400 (EDT) Message-ID: <48AD6EFE.6020205@3gfp.com> Date: Thu, 21 Aug 2008 13:43:00 -0000 From: Richard Harvey Chapman User-Agent: Thunderbird 2.0.0.16 (Macintosh/20080707) MIME-Version: 1.0 To: gcc Subject: Re: Macro question regarding single quotes References: <48A5E959.6050505@3gfp.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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/msg00215.txt.bz2 Perfect! And so simple. Thanks, H. Bernd Jendrissek wrote: > 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!