I needed to make some shared libraries in C++ and I used linux as my developer operating system. I know that I need to make symbols visible if I want to load them via dlsym
/LoadLibrary
. So in linux all of my symbols followed this pattern:
extern "C" [[gnu::visibility("default")]] void f();
I used clang with C++11 enabled and I was able to load f
in my host program. When I moved to windows I used GCC 4.8.2 with C++11 enabled and that pattern worked on windows machine too with LoadLibrary
. (I needed to use C++11 for new attribute syntax). I know that on windows I need to use __declspec(dllexport)
to export symbols from shared library. So what now? Is __declspec(dllexport)
not required anymore?
Edit:
I found here that those are synonyms (I think) so the question is that is there an [[gnu::attribute]]
for __declspec(dllimport)
to avoid using macros and ifdef
s for specific targets?
[[gnu::dllexport]]
is for GCC only, isn't it? Is there anything like this, that works under Clang and MSVC too? – Demonology