Skip to content

Latest commit

 

History

History
34 lines (27 loc) · 1004 Bytes

compiler-warning-level-1-c4165.md

File metadata and controls

34 lines (27 loc) · 1004 Bytes
description title ms.date f1_keywords helpviewer_keywords
Learn more about: Compiler Warning (level 3, off) C4165
Compiler Warning (level 3, off) C4165
11/04/2016
C4165
C4165

Compiler Warning (level 3, off) C4165

'HRESULT' is being converted to 'bool'; are you sure this is what you want?

When an HRESULT is used in an if statement, the HRESULT is converted to a bool unless you explicitly test for the variable as an HRESULT.

Warning C4165 is off by default. For more information, see Compiler Warnings That Are Off By Default.

Example

The following sample generates C4165:

// C4165.cpp
// compile with: /W3
#include <windows.h>
#pragma warning(3:4165)

extern HRESULT hr;
int main() {
   if (hr) {
   // try either of the following ...
   // if (FAILED(hr)) { // C4165 expected
   // if (hr != S_OK) {
   }
}