Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting the use of HRESULTs as bools

We have a big body of code that was refactored so that stuff which was plain-old C++ is now COM.

I've been spending the last couple of days hunting out places in which we missed the fact that a function that previously returned a bool now returns an HRESULT (the problem is compound by the fact that S_OK == false).

Is there a way to detect places in which an HRESULT is being used as a bool (and vice versa)?

We're using Visual Studio 2005 (VS8) Professional.

Is there anything other than @Steve's excellent suggestion which doesn't involve installing Team Edition?

like image 578
Motti Avatar asked Dec 17 '25 22:12

Motti


1 Answers

Are you using Code Analysis for C++?

If so, you should see

C6214 per http://msdn.microsoft.com/en-us/library/yy6dx731.aspx

or

C6217 per http://msdn.microsoft.com/en-us/library/z5aa1ca1.aspx

Also verify your source code (via #pragma) and project options do not disable these or other important warnings.

like image 200
Steve Townsend Avatar answered Dec 19 '25 15:12

Steve Townsend



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!