title: C++ [[gnu::visibility("default")]] vs __declspec(dllexport) on Windows and Linux
body: <p>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 <code>dlsym</code>/<code>LoadLibrary</code>. So in linux all of my symbols followed this pattern:</p>
  
  <pre><code>extern "C" [[gnu::visibility("default")]] void f();
  </code></pre>
  
  <p>I used clang with C++11 enabled and I was able to load <code>f</code> 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 <code>LoadLibrary</code>. (I needed to use C++11 for new attribute syntax). I know that on windows I need to use <code>__declspec(dllexport)</code> to export symbols from shared library. So what now? Is <code>__declspec(dllexport)</code> not required anymore?</p>
  
  <p>Edit:</p>
  
  <p>I found <a href="https://gcc.gnu.org/onlinedocs/gcc-4.9.1/gcc/Function-Attributes.html#Function-Attributes" rel="noreferrer">here</a> that those are synonyms (I think) so the question is that is there an <code>[[gnu::attribute]]</code> for <code>__declspec(dllimport)</code> to avoid using macros and <code>ifdef</code>s for specific targets?</p>