Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!ccicpg!leo!john From: john@leo.UUCP ( John McCurry) Newsgroups: comp.lang.c Subject: Re: Second question on #define Message-ID: <1473@leo.UUCP> Date: Wed, 4-Nov-87 13:00:35 EST Article-I.D.: leo.1473 Posted: Wed Nov 4 13:00:35 1987 Date-Received: Sat, 7-Nov-87 10:19:05 EST References: <10104@brl-adm.ARPA> Organization: CCI CPD (Advanced Development), Irvine CA Lines: 25 Summary: methods to expand variable names In article <10104@brl-adm.ARPA>, ultra!wayne@ames.arpa (Wayne Hathaway) writes: > I have a large number of manifest constants of the form > GREATBIGLONGPREFIX_SHORTTHING > > I would like to have a macro accept only SHORTTHING as an argument but > use the full constant name in the generated code. I (naively) tried > #define WIDGET(x) printf("%d\n", GREATBIGLONGPREFIX_x) Our compiler uses the "Reiser" (spelling?) version of cpp. This version uses /**/ for concatinating things - as in: #define WIDGET(x) printf("%d\n", GREATBIGLONGPREFIX_/**/x); or #define WIDGET(x) printf("%d\n", x/**/_GREATBIGLONGSUFFIX); I don't have access to an ANSI standard compiler but our local expert says that PREFIX_##x will (should) work. I am not, by the way, a compiler guru - I just use the beasts. Any mistakes in the above posting are probably accidental. -- John J. McCurry Computer Consoles Inc. CPD, Irvine, Ca. uunet!ccicpg!leo!john