🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

"FAILED(ddrval)" or "ddrval==DD_OK"

Started by
1 comment, last by SikCiv 24 years, 6 months ago
Yes, FAILED and SUCCEEDED are preferred over checking against DD_OK, or S_OK. This is because it is possible for COM interfaces to return multiple success values.

Advertisement
I havnt had any instances, but is 'FAILED(ddrval)' better to use than 'ddrval == DD_OK" when checking for DirectX return errors?

  Downloads:  ZeroOne Realm

Using the FAILED/SUCCEEDED macros is definitely the preferred method. I've occasionally heard the argument that they are slower than the check for == DD_OK; however, here's the definition of the macros:

code:
#define SUCCEEDED(Status) ((HRESULT)(Status) >= 0)#define FAILED(Status) ((HRESULT)(Status)<0)

Since macros are inserted before compilation, there shouldn't be any speed decrease doing it this way.

- Dave

This topic is closed to new replies.

Advertisement