I am trying to understand a typedef but I am stuck with this Code:
typedef _Return_type_success_(return == DUPL_RETURN_SUCCESS) enum
{
DUPL_RETURN_SUCCESS = 0,
DUPL_RETURN_ERROR_EXPECTED = 1,
DUPL_RETURN_ERROR_UNEXPECTED = 2
}DUPL_RETURN;
My question is:
1) What is the Return argument doing in parameter of a function
2) we usually define typedef like this
typedef int foo;
I am unable to understand this above format.
I am a noobee to serious c++ programming, Thankyou for your time.
EDIT: I am trying to build this streaming app, so I need to retrieve frames as fast as possible, I came across a few articles that recommended DXGI way which is a fast solution. I am trying to understand how to use the windows desktop Duplication API. I found this code on official msdn website : here
_Return_type_success_
it is not part of the official c++ standard, but part of the Microsoft source code annotation language (which is proprietary addition to the c++ syntax):
Using SAL Annotations to Reduce C/C++ Code Defects
SAL is the Microsoft source code annotation language. By using source code annotations, you can make the intent behind your code explicit. These annotations also enable automated static analysis tools to analyze your code more accurately, with significantly fewer false positives and false negatives.
And _Return_type_success_
itself is described in Success/Failure Annotations
_Return_type_success_(expr)
: May be applied to atypedef
. Indicates that all functions that return that type and do not explicitly have_Success_
are annotated as if they had_Success_(expr)
._Return_type_success_
cannot be used on a function or a function pointer typedef.
_Return_type_success_
is most certainly just a macro defined as #define _Return_type_success_(arg)
so that it is completely removed while compiling. This is at least the case for the sal.h
(no_sal2.h
) header used in some azure code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With