Explanation of HRESULT declaration / definition

I just looked at the definition HRESULTin VS2008. WinNT.h has the following line:

typedef __success(return >= 0) long HRESULT;

What exactly does this mean? It doesn't even look like C or C ++ to my unprepared eye.

+3
source share
3 answers

This is an annotation. Shortly speaking,

__success(expr)

means it exprdescribes the conditions under which a function is considered successful. For functions that return HRESULT, this condition is that the return value (because it HRESULTis equal long) is non-negative. All functions that return HRESULTuse this annotation to them because of this typedef.

, , MSDN SAL , HRESULT Win32 .

+5

Windows API . .

__ :

sal.h:

#define __success(expr)                     __inner_success(expr)

... inner_success :

#define __inner_success(expr)

... . , typedef HRESULT :

typedef long HRESULT;
0

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


All Articles