The Evil of MacrosMarch 10th, 2010
I was doing some work on an XInput extension for Ruby, and after making some changes I stopped getting controller input data. I had a look, and somehow I’d done this :
XINPUT_STATE state;
if( SUCCEEDED( controllerIndex, &state ) )
{
...
}
Instead of:
XINPUT_STATE state;
if( SUCCEEDED( XInputGetState( controllerIndex, &state ) ) )
{
...
}
Of course, SUCCEEDED was perfectly happy with this, since the following is perfectly valid code. Unusual, but valid.
XINPUT_STATE state;
if( ((HRESULT)(controllerIndex, &state)) >= 0 )
{
...
}
Evil.