I needed to make some common C ++ libraries, and I used linux as my developer operating system. I know that I need to make characters visible if I want to load them through dlsym / LoadLibrary . Thus, on linux, all of my characters follow this pattern:
extern "C" [[gnu::visibility("default")]] void f();
I used clang with C ++ 11 enabled, and I managed to load f in my host program. When I switched to windows, I used GCC 4.8.2 with C ++ 11 enabled, and this template worked on a Windows machine also with LoadLibrary . (I needed to use C ++ 11 for the new attribute syntax). I know that in windows I need to use __declspec(dllexport) to export characters from a shared library. And now what? Is __declspec(dllexport) no longer required?
Edit:
I found here that these are synonyms (I think), so the question is what exists [[gnu::attribute]] for __declspec(dllimport) to avoid using macros and ifdef for specific purposes?
c ++ visibility attributes
Szลke szabolcs
source share