Question

A lot o functions in OpenNI return like this:

XN_C_API XnInt32 XN_C_DECL  xnVersionCompare (const XnVersion *pVersion1, const XnVersion *pVersion2)

I'd like to now what is XN_C_API and XN_C_DECL. Just curiosity!

Was it helpful?

Solution

It's not anything to do with the return value. Without looking at the source, I suspect that when compiling for Windows:

  • XN_C_API gets defined to either __declspec(dllexport) or __declspec(dllimport) depending on whether you're compiling the DLL or importing functions from it.

  • XN_C_DECL gets defined to the desired calling convention for the function (probably __stdcall or __cdecl)

OTHER TIPS

Without having looked at the definitions, I'd guess:

  • XN_C_API is effectively extern "C" for a C++ compiler so that a C function can be called from C++.

  • XN_C_DECL deals with the calling conventions and export/import issues imposed by Windows. That might be __declspec(ddlexport) or __declspec(dllimport), and it might include __stdcall etc, and might also worry about FAR etc (but probably doesn't need to any more).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top