问题
I am trying to get familiar with the Kinect 2.0 SDK in c++ in order to create my own program. However, I am getting stuck with understanding some of the code. First of all, as I tried to trace back different structure declarations, I found that all of the functions are virtual and I cannot find where they are actually defined. For example, If you are in visual studio, and click on 'IBody' and open declaration, it brings you to an interface where everything is virtual. How can I figure out where everything is actually defined?
I tried tracing back through other functions, and I eventually got stuck on "GetDefaultKinectSensor". The definition for this function is
HRESULT WINAPI GetDefaultKinectSensor(_COM_Outptr_ IKinectSensor** defaultKinectSensor);
How is this a function declaration? Could anyone explain this to me?
I understand the basics of C++ but this is new territory for me.
Thanks!
回答1:
It is a function that has the following signature:
HRESULT WINAPI GetDefaultKinectSensor(_COM_Outptr_ IKinectSensor** defaultKinectSensor);
//^return type ^calling convention ^name ^annotation ^argument type
named - GetDefaultKinectSensor
returns - HRESULT
calling convention - WINAPI
argument annotation - _COM_Outptr_
argument type - IKinectSensor**
Note that the _COM_Outptr_
annotation has the following description:
The returned pointer has COM semantics, and therefore carries an _On_failure_ post-condition that the returned pointer is null.
The bare function signature would be
HRESULT GetDefaultKinectSensor(IKinectSensor** defaultKinectSensor);
Perhaps the calling convention and argument annotation are throwing you off a bit.
来源:https://stackoverflow.com/questions/30899558/advanced-c-interfaces-tracing-kinect-skd-2-0-code