Hey Mugsy:
Did you ever figure this out? I was browsing the comp.lang.c newsgroup FAQ
(ok, somebody needs a life :P), and found this:
Question 11.17
I'm trying to use the ANSI ``stringizing'' preprocessing operator `#' to
insert the value of a symbolic constant into a message, but it keeps
stringizing the macro's name rather than its value.
-----------------------------------------------------
You can use something like the following two-step procedure to force a macro
to be expanded as well as stringized:
#define Str(x) #x
#define Xstr(x) Str(x)
#define OP plus
char *opname = Xstr(OP);
This code sets opname to "plus" rather than "OP".
An equivalent circumlocution is necessary with the token-pasting operator ##
when the values (rather than the names) of two macros are to be
concatenated.
References: ANSI Sec. 3.8.3.2, Sec. 3.8.3.5 example
ISO Sec. 6.8.3.2, Sec. 6.8.3.5
http://www.eskimo.com/~scs/C-faq/q11.17.html
I think you were trying to get the preprocessor to expand and then
'stringize' your #define'd constant, passing it's value as the arg to your
func, which is what that code appears to do.
Pat 'sluggo' Magnan
Tour of Duty Mod
http://www.tourofdutymod.com
----- Original Message -----
From: "Mugsy _" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, May 07, 2002 2:29 AM
Subject: Re: [hlcoders] string to #define
> > > > > > > > The pre-processors scan through source files replacing the
> >define
> > > >with
> > > > > > > > the value.
> > > > > > > >
> > > > > > > > I'm not 100% sure, but about 95% that it looks in strings as
> >well,
> > > >so
> > > > > > > >
> > > > > > > > someFuncThatTakesAString("WEAPON_GARAND");
> > > > > > > >
> > > > > > > > will get changed to
> > > > > > > >
> > > > > > > > someFuncThatTakesAString("2"); file://constant string 2\0
> > > > > > > >
> > > > > > > > before its compiled.
_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders