Yeah I thought about that but I think it ends up with a lot of string
compares. The particular method I am thinking of ( I might be remembering
some magical C++ dream I had ) acutally involved converting a string into a
variable name directly.

But I'm most likely on crack.



>From: "Josh Coyne" <[EMAIL PROTECTED]>
>Reply-To: [EMAIL PROTECTED]
>To: <[EMAIL PROTECTED]>
>Subject: Re: [hlcoders] string to #define
>Date: Mon, 6 May 2002 23:25:33 -0400
>
>hmm
>
>a possible idea could be a string table maybe
>
>an array of string/code structs, like
>
>typedef struct
>{
>     char cStringId[256];
>     int iId;
>}weaponchar_id_t;
>
>then you could perhaps have like
>
>weaponchar_id_t WeaponCodes[] = {
>     { "WEAPON_GARAND",2 },
>     { "WEAPON_1911", 1},
>     NULL,
>     // etc
>};
>
>then have a support function or two to grab the string/int and compare in
>this array
>this could be more work, who knows, but here it looks a bit easier to just
>reference similar items in an array
>
>----- Original Message -----
>From: "Dynerman David M" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Sent: Monday, May 06, 2002 11:10 PM
>Subject: RE: [hlcoders] string to #define
>
>
> > Well they say when you're not sure try..so I did and Leon's right (at
> > least with VC++)
> >
> > I'm not sure where I saw/read that it would scan quotes, but the define
> > didn't work for me (it would just print out WEAPON_GARAND instead of 2)
> >
> > Looks like we're stuck defining string literals or numbers, but not
> > mixing & matching.
> >
> > david
> >
> > -----Original Message-----
> > From: Leon Hartwig [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, May 06, 2002 9:50 PM
> > To: '[EMAIL PROTECTED]'
> > Subject: RE: [hlcoders] string to #define
> >
> > I'm sure it depends on which preprocessor is being used, but I doubt
> > most
> > modern ones do this.
> >
> >
> > > -----Original Message-----
> > > From: Dynerman David M [mailto:[EMAIL PROTECTED]]
> > > Sent: Monday, May 06, 2002 7:35 PM
> > > To: [EMAIL PROTECTED]
> > > 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"); //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
> >
> > _______________________________________________
> > To unsubscribe, edit your list preferences, or view the list archives,
>please visit:
> > http://list.valvesoftware.com/mailman/listinfo/hlcoders
> >
>
>_______________________________________________
>To unsubscribe, edit your list preferences, or view the list archives,
>please visit:
>http://list.valvesoftware.com/mailman/listinfo/hlcoders


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.

_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to