public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Eljay Love-Jensen <eljay@adobe.com>
To: "Buddy Lott" <buddy_lott@hotmail.com>
Cc: gcc-help@gcc.gnu.org
Subject: RE: CPP (preprocessor) quandry
Date: Fri, 22 Nov 2002 10:32:00 -0000	[thread overview]
Message-ID: <4.3.2.7.2.20021122122636.00b60e00@iplan-mn.corp.adobe.com> (raw)
In-Reply-To: <583E84A77A2FCB4F967E6CD9B0CA4AF74E4906@nt-server.kreuter>

Hi Buddy,

Thanks for the idea!

This "two-part macro" trick will work:
#define $MkEnum(name$) \
struct name$ {\
   typedef enum {

#define $EndEnum(name$) \
   } Type;\
   Type m;\
   name$(Type in) : m(in) { }\
   operator Type () const { return m; }\
}

In use:

$MkEnum(Marx)
	Groucho, Chico, Harpo, Gummo, Zeppo, Karl = 86
$EndEnum(Marx);

Voila!  Slightly awkward, but acceptable.  It could all be put on one line, 
but I'm not sure if that'd be better or worse.

Note:  C++ only, no C.

Thanks,
--Eljay

      reply	other threads:[~2002-11-22 18:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-29 14:51 Problem compiling GCC 3.2 on i686-pc-linux: "not enough room for program headers" Francis Hwang
2002-10-29 17:11 ` Ben Elliston
2002-10-30  9:55   ` Francis Hwang
2002-10-30 17:02     ` Ben Elliston
2002-10-31 11:16       ` Francis Hwang
2002-11-22  9:17     ` CPP (preprocessor) quandry Eljay Love-Jensen
2002-11-22  9:43       ` Buddy Lott
2002-11-22 10:06         ` Eljay Love-Jensen
2002-11-22 10:11           ` Buddy Lott
2002-11-22 10:32             ` Eljay Love-Jensen [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=4.3.2.7.2.20021122122636.00b60e00@iplan-mn.corp.adobe.com \
    --to=eljay@adobe.com \
    --cc=buddy_lott@hotmail.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).