T.R | Title | User | Personal Name | Date | Lines |
---|
2129.1 | | SPECXN::DERAMO | Dan D'Eramo | Thu Mar 27 1997 10:49 | 7 |
| Convoluted or not, that is the "standard" way to do it. I
can't remember any similar how-to notes that suggested
anything else.
Convoluted is in the eye of the beholder. :-)
Dan
|
2129.2 | that 's it | DECC::PARKS | | Thu Mar 27 1997 13:52 | 3 |
| Dan's right. That's the way to do it.
\John (cpp author)
|
2129.3 | "Standard" way to do it | DECCXL::RMEYERS | Randy Meyers | Thu Mar 27 1997 14:49 | 4 |
| In fact, .0 closely matches the example in the ANSI C Standard showing
how this stuff works.
Think of the technique as just another C idiom to be learned.
|
2129.4 | How do I do this with /STANDARD=VAXC? | SMAUG::GARROD | IBM Interconnect Engineering | Thu Mar 27 1997 18:05 | 20 |
| Interesting. I came here to ask about the same question. But I need
this to work with
/STANDARD=VAXC
so my question is:
How do I get the vakue of FOO (which is 123) to be expanded to "123"
when using /STANDARD=VAXC.
I beliebe the reason the technique in .0 doesn't work with
/STANDARD=VAXC is because of the Incompatible Common C extension
documented on page D2 of the DECC manual.
"During macro replacement, an argument's preprocessing tokens are NOT
macro replaced before the macro is expanded".
So I guess my question is how can I get them macro expanded?
Dave
|
2129.5 | | SPECXN::DERAMO | Dan D'Eramo | Thu Mar 27 1997 20:33 | 18 |
| In /STANDARD=COMMON mode, the following
#define Q2(s) "s"
#define Q(x) Q2(x)
#define FOO 123
static const char foo[] = Q(FOO);
yields
static const char foo[] = "123";
but in /STANDARD=VAXC mode it yields
static const char foo[] = "FOO";
Dan
|
2129.6 | What's the reason for COMMON and VAXC to be different here? | EDSCLU::GARROD | IBM Interconnect Engineering | Fri Mar 28 1997 09:45 | 15 |
| Re .5
Yes this is axactly the issue I'm asking about. What is it that defines
the behaviour of /STANDARD=COMMON to be different from /STANDARD=VAXC
in this regard. The documentation implies that COMMON is a subset of VAXC.
I've now tried every way I can think of to get quoting and substitution
to happen at the same time. I can't find any way that seems to work
/STANDARD=VAXC. Unfortunately I need to use /STANDARD=VAXC because
I don't have the time available right now to make all the countless
lines of code ANSI compliant.
Thanks,
Dave
|
2129.7 | can't do it in -vaxc mode | DECC::PARKS | | Fri Mar 28 1997 16:57 | 22 |
| Re .4
I do not know of any way to stringize the expansion of a macro
in VAXC mode. And your reasoning is correct -- it's because in
VAXC mode, macro arguments are never expanded before substitution.
I tried vaxc (the real compiler) and could find no way to do it
with that compiler either.
Re .6
Sorry for the confusion. COMMON is not a subset of VAXC though
they are close. COMMON is intended to match the behavior of the
pcc compiler on UNIX systems. VAXC is intended to match the
behavior of the vaxc compiler.
I can think of at least one other difference in the macro processor:
VAXC mode allows for recursive macro expansion, COMMON doesn't.
Have you tried COMMON mode? That may be your best bet.
\John
|