As the title say, when i try to compile my program I receive a debug error which says:
Error 7 error C2446: '>=' : no conversion from 'DWORD' to 'const char *'
Some code:
virtual CBaseDecorator* __Clone(CParticleInstance* pfi, CParticleInstance* pi)
{
return new CTextureAnimationCWDecorator(
fFrameTime,n,(BYTE*)((unsigned char*)pi+((BYTE*)pIdx-(BYTE*)pfi)));
}
virtual void __Excute(const CDecoratorData & d)
{
fLastFrameTime -= d.fElapsedTime;
while (fLastFrameTime<0.0f)
{
fLastFrameTime += fFrameTime;
if (++(*pIdx) >= n) // error line
*pIdx = 0;
}
}
DWORD n;
float fLastFrameTime;
float fFrameTime;
BYTE* pIdx;
};
How can I solve this?
There is a simple solution you have to cast the BYTE type to DWORD or the opposite like:
if (++(*pIdx) >= (BYTE)n) // error corrected
But this does lead me to question what you are doing. A DWORD is a much bigger storage that the BYTE type the pointer addresses - this comparison therefore looks dangerously like a spot where a subtle overflow bug might occur when n > 255.
Also you ruse of the ++ operator seems confusing - are you clear that this operator is NOT incrementing the pointer onto the next byte, but rather incrementing the value of the byte currently pointed to?