LAZPERF_EXPORT macro is wrong on Windows
SpaceIm opened this issue · 5 comments
SpaceIm commented
LAZPERF_EXPORT
macro is defined in lazperf.h
: https://github.com/hobu/laz-perf/blob/2e3c316248fa534cdeba1b47b2e9fe1a0ecf5dca/cpp/lazperf/lazperf.hpp#L42-L47
It's broken on Windows.
- If static, this macro should be empty (all OS)
- If shared, this macro should be:
- Windows:
__declspec(dllexport)
at build time, and__declspec(dllimport)
at consume time - others OS:
__attribute__((visibility ("default")))
- Windows:
abellgithub commented
What specific problem is the current code causing? What errors/failures are occurring?
SpaceIm commented
I've not tested yet, I'm packaging laz-perf for conan, but I already know it's a wrong logic, probably leading to undefined references or lot of warnings.
abellgithub commented
Then maybe you should test it and report on errors that you find.
…On Sun, May 30, 2021, 7:31 AM SpaceIm ***@***.***> wrote:
I've not tested yet, I'm packaging laz-perf for conan, but I already know
it's a wrong logic, probably leading to undefined references or lot of
warnings.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#80 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAKBMMGXNVPG6XWOYKVS32LTQIOXRANCNFSM45ZH3F3Q>
.
SpaceIm commented
The logic should be something like this:
#ifdef LAZPERF_SHARED
# ifdef _WIN32
# ifdef LAZPERF_BUILD
# define LAZPERF_EXPORT __declspec(dllexport)
# else
# define LAZPERF_EXPORT __declspec(dllimport)
# endif
# else
# define LAZPERF_EXPORT __attribute__((visibility ("default")))
# endif
#else
# define LAZPERF_EXPORT
#endif
Then in CMakeLists.txt in lazperf subfolder:
target_compile_definitions(${LAZPERF_SHARED_LIB} PRIVATE LAZPERF_BUILD PUBLIC LAZPERF_SHARED)
abellgithub commented
I changed things so that the installed code will, by default, offer __declspec(dllimport), not that it matters much.