No longer require MODULE_EXPORTS and fix related issues #435
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
MMDevice (in
ModuleInterface.h
) conditionally definedMODULE_API
based on whetherMODULE_EXPORTS
was defined. The intent was (presumably) that device adapters would defineMODULE_EXPORTS
and therefore expose the module interface functions such asInitializeModuleData()
(defined by the device adapter) andGetNumberOfDevices()
(defined inModuleInterface.cpp
), whereasMODULE_EXPORTS
would not be defined when building MMCore so that those functions are not included.In practice, there were a few issues:
MODULE_EXPORTS
, so the device module interface functions were being included inMMCoreJ_wrap.dll
(this is harmless).MODULE_EXPORTS
was not defined,MODULE_API
was incorrectly defined to__declspec(dllimport)
, which is irrelevant when libraries are loaded viaLoadLibrary()
. This also meant thatModuleInterface.cpp
did not compile on Windows withoutMODULE_EXPORTS
defined.MODULE_EXPORTS
was never defined in any case (and had no effect either). The module interface functions were being included inlibMMCoreJ_wrap
(again, harmless).MODULE_EXPORTS
is too generic.So this PR replaces
MODULE_EXPORTS
with another macro,MMDEVICE_CLIENT_BUILD
, with roughly the opposite meaning. Device adapters no longer need to define any macro, whereas building MMCore should defineMMDEVICE_CLIENT_BUILD
.In addition,
MODULE_API
is now defined for GCC/Clang to explicitly give the functions default visibility, so that we can use-fvisibility=hidden
when building device adapters in the future (doing so has a number of advantages but is not urgent).To work around the way our Visual Studio and Autotools builds work (i.e., the common MMDevice static library), it is still possible to build MMCore using an MMDevice static library built without
MMDEVICE_CLIENT_BUILD
, as long asMMDEVICE_CLIENT_BUILD
is defined when including the MMDevice headers during the MMCore build. This is similar to howMODULE_EXPORTS
was previously being used on Windows.MMCoreJ_wrap
will expose unnecessary symbols, but this is the same as the previous situation.Note that device adapters (including any that are outside of this repo) do not need to change: defining
MODULE_EXPORTS
now has no effect but also does not do any harm.It would be nice to also rename
MODULE_API
to something likeMMDEVICE_API
, but that would require changing the source code of all device adapters; probably not worth the disruption at this time. I did make it so thatMODULE_API
is not defined whenMMDEVICE_CLIENT_BUILD
is defined.Finally, none of this affects the device interface version.
Manual testing
CreateDevice
CreateDevice
CreateDevice
MMDEVICE_CLIENT_BUILD
added)