Thread View: comp.std.c
1 messages
1 total messages
Started by Cornelia Boldyreff
Mon, 15 Aug 1988 17:26
Re: Concatenating tokens that aren't parameters to macros in ANSI C
Author: 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.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads