MSVC: handle symbol visibility

On MSVC, the exported symbols have to be marked both in the header and
in the implementation as dllexport, whereas on GCC the visibility=normal
attribute is only supposed to be used in the implementation. As a
result, we need two types of macros here, one for the public headers,
and the other for TUs with implementation. Also, the symbol name cannot
be generic ("API") because we only want to mark as dllexport those
symbols which are in a library that we're building *now*. Otherwise this
will break havoc in any libraries which also use the `ABI` macro *and*
also use libyang.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5737745..1764a5f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -337,7 +337,10 @@
 else()
     set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
     add_library(yangobj OBJECT ${libsrc} ${compatsrc})
-    set_target_properties(yangobj PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
+    if(NOT WIN32)
+        set_target_properties(yangobj PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
+    endif()
+    target_compile_definitions(yangobj PRIVATE LIBYANG_BUILD)
     add_library(yang SHARED $<TARGET_OBJECTS:yangobj>)
 
     #link dl