Single quotes around an evaluated #define?
Tom Poage
poage at sunny.UUCP
Sun Nov 6 17:39:00 AEST 1988
Hope this is appropriate . . . so here goes.
I am working on an application in Unify's Accell which uses
cpp for preprocessing. In order to gain some consistency and
reduce the volume of this 4GL code, I would like to split the
files into a number of (mostly) redundant modules. At the
point where this module is to be inserted, I take care of
a couple of defines and insert an #include. Now, the problem
is this: Accell quotes literal strings in single quotes. What
sorts of contortions are required to evaluate a define and
insert it into single quotes using the cpp mechanism. Any
experiments/RTFMing don't come up with anything. Here's what
I would like it to do:
#ifdef CURRENT_TABLE
#undef CURRENT_TABLE
#define CURRENT_TABLE mytable
#endif
#include "mymodule"
where "mymodule" should eventually contain
SET mytable:$foobar TO 'mytable'
as a result of somthing like
SET CURRENT_TABLE:$foobar TO 'CURRENT_TABLE' <-- Hah! Evaluate this!
I can do somthing like add the literal as an additional definition;
but that's too easy:
#define CURRENT_TABLE_NAME 'mytable'
Anyhow, I thought I would see what the folks in netland had to say to
this musing. This could be useful to others in C.
--
Tom Poage, UCDMC Clinical Engineering, Sacto., CA
ucdavis.ucdavis.edu!sunny!{poage,root,postmaster,news}
ucbvax!ucdavis!sunny!{poage,root,postmaster,news}
More information about the Comp.lang.c
mailing list