views:

69

answers:

1

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?

+3  A: 

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.

Steve Townsend
Yes we are compiling with /W4 as well as /WX (treat warnings as errors) but we're not getting any such warnings). The links you sent are for VS10 do you know if they are relevant for VS8? (No pragmas are present)
Motti
@Motti - my bad - these come from "Code Analysis for C++" not just regular compiler warnings. See edit.
Steve Townsend
Sounds promising, where do I download it from (I have an MSDN subscription)
Motti
@Motti - it should be built in if you have VS2005 installed under your MSDN subscription. See here for where to find it in the IDE: http://msdn.microsoft.com/en-us/library/6yz6c9dy(v=VS.80).aspx. This slows down the build quite a bit so I don't run with it on all the time.
Steve Townsend
@Motti - this is in 'Team Edition' - does your subscription cover that?
Steve Townsend
Thanks Steve, I'm not sure, I'll check.
Motti