home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!crdgw1!rdsunx.crd.ge.com!bart!volpe
- From: volpe@bart.NoSubdomain.NoDomain (Christopher R Volpe)
- Newsgroups: comp.lang.c
- Subject: Re: Concatenation of two macros?
- Message-ID: <1992Jul23.203328.26199@crd.ge.com>
- Date: 23 Jul 92 20:33:28 GMT
- References: <1FE7B81211DF800725@ursula.lucas.lu.se> <1992Jul23.152318.8369@progress.com>
- Sender: volpe@bart (Christopher R Volpe)
- Reply-To: volpe@ausable.crd.ge.com
- Organization: GE Corporate Research & Development
- Lines: 41
- Nntp-Posting-Host: bart.crd.ge.com
-
- In article <1992Jul23.152318.8369@progress.com>, briggs@progress.COM (Scott Briggs) writes:
- |> KOSU_MATSB@ROUTH.KOSUFY.LU.SE writes:
- |>
- |>
- |> > Concatenation of two macros. Is it possible?
- |>
- |> > If i have the following two definitions:
- |> > #define A pre
- |> > #define B post
- |> > And want to "#define C" to be "prepost" BUT as an
- |> > expression of A and B! How do i do it?
- |> > #define C (expression of A and B to yield prepost)
- |>
- |> Depending on the compiler one of the following should work:
- |>
- |> #define C A##B
-
- On what broken compiler does the above not yield "AB"???
-
- |>
- |> or
- |>
- |> #define C A/**/B
-
- I believe most pre-ANSI compilers will yield "AB" for that too.
-
- And if you're interested in a solution that actually works on ANSI
- conforming compilers, try the following:
-
- #define A pre
- #define B post
- #define CATX(x,y) x ## y
- #define CAT(x,y) CATX(x,y)
- #define C CAT(A,B)
-
-
- --
- ==================
- Chris Volpe
- G.E. Corporate R&D
- volpecr@crd.ge.com
-