Article View: comp.std.c
Article #5269Re: Concatenating tokens that aren't parameters to macros in ANSI C
From: Cornelia Boldyreff
Date: Mon, 15 Aug 1988 17:26
Date: Mon, 15 Aug 1988 17:26
28 lines
1234 bytes
1234 bytes
Regarding item on this subject from: gnu@hoptoad.uucp (John Gilmore)
Under pcc:
>#define LFD 6
>#define LHIGH 1.0e+LFD
which expanded LHIGH to
>1.0e+6
and the problems he's had getting this to work in ANSI C with gcc.
There is a simple solution given below:
#define paste(a,b) a ## b
#define xpaste(a,b) paste(a,b)
#define LFD 6
#define LHIGH xpaste(1.0e+, LFD)
main(){printf("%f\n", LHIGH);}
and it works correctly with gcc.
The point is that the paste macro if called through another macro will
work on macro replaced operands. I've explained this more fully in an article
which appeared in the EUUG newsletter: Macro Expansion as Defined by the
ANSI/ISO Draft Standard, Volume 8, No 2, Summer 1988.
Cornelia Boldyreff
Department of Computer Science
Brunel University
Uxbridge UB8 3PH, ENGLAND.
Technical Details
Message-ID:
<453@Terra.cc.brunel.ac.uk>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcvax!ukc!reading!onion!bru-cc!cssrccbShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcvax!ukc!reading!onion!bru-cc!cssrccb From: cssrccb@cc.brunel.ac.uk (Cornelia Boldyreff) Newsgroups: comp.std.c,comp.lang.c Subject: Re: Concatenating tokens that aren't parameters to macros in ANSI C Keywords: paste operator cpp preprocess Message-ID: <453@Terra.cc.brunel.ac.uk> Date: 15 Aug 88 17:26:25 GMT Organization: Brunel University, Uxbridge, UK Lines: 28