www.digitalmars.com         C & C++   DMDScript  

D - constant problem

reply "Sean L. Palmer" <seanpalmer directvinternet.com> writes:
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

}
Jan 28 2003
next sibling parent "Sean L. Palmer" <seanpalmer directvinternet.com> writes:
In fact, I *can't* change them to enum, because of the scoping rules for

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

 }
Jan 28 2003
prev sibling parent reply "Sean L. Palmer" <seanpalmer directvinternet.com> writes:
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

 }
Jan 28 2003
parent Evan McClanahan <evan dontSPAMaltarinteractive.com> writes:
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
Jan 28 2003