Thread overview
constant problem
Jan 28, 2003
Sean L. Palmer
Jan 28, 2003
Sean L. Palmer
Jan 28, 2003
Sean L. Palmer
Jan 28, 2003
Evan McClanahan
January 28, 2003
Ahh, c'mon!  This is a constant expression!  This used to work.  I don't wanna have to change all these to enums.

Sean


const uint D3DSP_DSTMOD_SHIFT = 20;

const uint D3DSP_DSTMOD_MASK = 0x00F00000;

enum D3DSHADER_PARAM_DSTMOD_TYPE

{

D3DSPDM_NONE = 0<<D3DSP_DSTMOD_SHIFT, // nop   // ERROR:  expects constant expression

D3DSPDM_SATURATE= 1<<D3DSP_DSTMOD_SHIFT, // clamp to 0. to 1. range

D3DSPDM_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum

}


January 28, 2003
In fact, I *can't* change them to enum, because of the scoping rules for enumeration members.  I'd have to do the C# thing with prepending the enum type name in front of every usage.

Sean

"Sean L. Palmer" <seanpalmer@directvinternet.com> wrote in message news:b15m57$aqb$1@digitaldaemon.com...
> Ahh, c'mon!  This is a constant expression!  This used to work.  I don't wanna have to change all these to enums.
>
> Sean
>
>
> const uint D3DSP_DSTMOD_SHIFT = 20;
>
> const uint D3DSP_DSTMOD_MASK = 0x00F00000;
>
> enum D3DSHADER_PARAM_DSTMOD_TYPE
>
> {
>
> D3DSPDM_NONE = 0<<D3DSP_DSTMOD_SHIFT, // nop   // ERROR:  expects constant expression
>
> D3DSPDM_SATURATE= 1<<D3DSP_DSTMOD_SHIFT, // clamp to 0. to 1. range
>
> D3DSPDM_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum
>
> }
>
>


January 28, 2003
Sorry... it only complains about const uint blah = 20;  if I change it to const int blah = 20, it works!!  Maybe it doesn't like the implicit cast?

Sean

"Sean L. Palmer" <seanpalmer@directvinternet.com> wrote in message news:b15m57$aqb$1@digitaldaemon.com...
> Ahh, c'mon!  This is a constant expression!  This used to work.  I don't wanna have to change all these to enums.
>
> Sean
>
>
> const uint D3DSP_DSTMOD_SHIFT = 20;
>
> const uint D3DSP_DSTMOD_MASK = 0x00F00000;
>
> enum D3DSHADER_PARAM_DSTMOD_TYPE
>
> {
>
> D3DSPDM_NONE = 0<<D3DSP_DSTMOD_SHIFT, // nop   // ERROR:  expects constant expression
>
> D3DSPDM_SATURATE= 1<<D3DSP_DSTMOD_SHIFT, // clamp to 0. to 1. range
>
> D3DSPDM_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum
>
> }
>
>


January 28, 2003
Sean L. Palmer wrote:
> Sorry... it only complains about const uint blah = 20;  if I change it to
> const int blah = 20, it works!!  Maybe it doesn't like the implicit cast?

There are constant markers (i, u, etc.) that make literals act like different types.  Have you tried those?   BTW, I'm of the opinion that anything expressed in hex should automatically be unsigned.  I think that it's a more logical default type.

Evan