iotivity-lite icon indicating copy to clipboard operation
iotivity-lite copied to clipboard

Export functions through DLL for other libraries to use

Open LordMike opened this issue 3 years ago • 2 comments

I'm not entirely sure how this is meant to work, but if I want to interop with the API from C#, I had to do the following:

  • Compile as a dll (please provide binaries :))
  • Add __declspec(dllexport) to functions, to ensure they're exported

Could these things be done in the project itself, so that I and others can interop with the produced binary?

LordMike avatar Feb 02 '22 22:02 LordMike

Yes, that can be done in the project, but in a portable way. This is often achieved with a pre-processor macro like this one: https://github.com/zeromq/libzmq/blob/master/include/zmq.h#L62

Oxymoron79 avatar Feb 04 '22 16:02 Oxymoron79

Yes, exactly. I had a hard time adding these locally, as there are so many methods, and I couldn't quickly identify which ones should be exported. It would have been easier if all public methods had been defined using a macro, so I could modify that and thereby add the export declaration.

A macro could be helpful also to ensure a consistent API surface, such as the oc_ prefix.

LordMike avatar Feb 04 '22 19:02 LordMike