0

I'm trying to create a cross-platform shared library targeted primarily on Windows and Linux. I'm using Clang. I'm trying to be somewhat consistent with the standard specification that's why I try to get rid of some MSVC extensions where possible. One of them are __declspec(dllimport) and __declspec(dllexport). What I found out is that clang offers attributes [[gnu::dllimport]] and [[gnu::dllexport]]. The question is: are they compatible with Linux or I will still have to write macro wrappers to write cross-platform code?

Article I've previously read

bub1ick
  • 21
  • 6
  • 2
    isnt this already answered by the Q&A you link ? I dont understand how this question is different – 463035818_is_not_an_ai Apr 04 '22 at 14:18
  • A quick test on https://gcc.godbolt.org/ reveals that they cause a warning on Linux. I wouldn't want to disable warnings for all unknown attributes, and the alternative is to wrap it in a macro to disable it on Linux. And at that point you might as well use `__declspec`, since it's supported by MSVC, unlike the attribute. – HolyBlackCat Apr 04 '22 at 14:23
  • Thanks for that @HolyBlackCat. Good to know. I guess I just have to do it the good old way :D – bub1ick Apr 04 '22 at 14:28

0 Answers0