Who is using the MFC VERIFY Macro?

To think ... there I programmed for a long time in an environment with MFC using ASSERT () when it seemed OK, and only today I (was) came across VERIFY Macro: http://msdn.microsoft.com/en-us/ library / fcatwy09% 28v = VS.71% 29.aspx

This is basically the same as ASSERT (), except that the expression will not be deleted in the release builds (there will be validation, but the expression will still be evaluated).

#ifdef _DEBUG
#define VERIFY(f)          ASSERT(f)
#else   // _DEBUG
#define VERIFY(f)          ((void)(f))

I see several uses for this, but I was wondering if others would use it regularly in their code base, and if someone saw any side effects of using it.

greetings.

+3
source share
3 answers

MFC, .

, -, , , , VERIFY. (, : CloseHandle)

, .

+3

, 15 , . ASSERT , . , , . ASSERT VERIFY s.

+2

, :

  ...
  const int optional_return_value = AnyOldFunctionOrMethod(params);
  ASSERT(optional_return_value == 42);
}

warning C4189: 'optional_return_value' : local variable is initialized but not referenced .

VERIFY Macro can avoid this by making a function call + check on one line in the VERIFY macro (for example, it will offer in its answer ) or simply using VERIFY instead of ASSERT in the control line.

0
source

Source: https://habr.com/ru/post/1756167/


All Articles