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/src/out.h b/src/out.h
index 7ecf347..e2fd0b1 100644
--- a/src/out.h
+++ b/src/out.h
@@ -104,7 +104,7 @@
  * @param[in] out Printer handler.
  * @return Type of the printer's output.
  */
-LY_OUT_TYPE ly_out_type(const struct ly_out *out);
+LIBYANG_API_DECL LY_OUT_TYPE ly_out_type(const struct ly_out *out);
 
 /**
  * @brief Reset the output medium to write from its beginning, so the following printer function will rewrite the current data
@@ -119,7 +119,7 @@
  * @return LY_SUCCESS in case of success
  * @return LY_ESYS in case of failure
  */
-LY_ERR ly_out_reset(struct ly_out *out);
+LIBYANG_API_DECL LY_ERR ly_out_reset(struct ly_out *out);
 
 /**
  * @brief Generic write callback for data printed by libyang.
@@ -141,7 +141,7 @@
  * @return LY_SUCCESS in case of success
  * @return LY_EMEM in case allocating the @p out handler fails.
  */
-LY_ERR ly_out_new_clb(ly_write_clb writeclb, void *user_data, struct ly_out **out);
+LIBYANG_API_DECL LY_ERR ly_out_new_clb(ly_write_clb writeclb, void *user_data, struct ly_out **out);
 
 /**
  * @brief Get or reset callback function associated with a callback printer handler.
@@ -151,7 +151,7 @@
  * printer callback is returned.
  * @return Previous printer callback.
  */
-ly_write_clb ly_out_clb(struct ly_out *out, ly_write_clb writeclb);
+LIBYANG_API_DECL ly_write_clb ly_out_clb(struct ly_out *out, ly_write_clb writeclb);
 
 /**
  * @brief Get or reset callback function's argument associated with a callback printer handler.
@@ -161,7 +161,7 @@
  * If NULL, only the current file descriptor value is returned.
  * @return The previous callback argument.
  */
-void *ly_out_clb_arg(struct ly_out *out, void *arg);
+LIBYANG_API_DECL void *ly_out_clb_arg(struct ly_out *out, void *arg);
 
 /**
  * @brief Create printer handler using file descriptor.
@@ -171,7 +171,7 @@
  * @return LY_SUCCESS in case of success
  * @return LY_ERR value in case of failure.
  */
-LY_ERR ly_out_new_fd(int fd, struct ly_out **out);
+LIBYANG_API_DECL LY_ERR ly_out_new_fd(int fd, struct ly_out **out);
 
 /**
  * @brief Get or reset file descriptor printer handler.
@@ -181,7 +181,7 @@
  * @return Previous value of the file descriptor. Note that caller is responsible for closing the returned file descriptor in case of setting new descriptor @p fd.
  * @return -1 in case of error when setting up the new file descriptor.
  */
-int ly_out_fd(struct ly_out *out, int fd);
+LIBYANG_API_DECL int ly_out_fd(struct ly_out *out, int fd);
 
 /**
  * @brief Create printer handler using file stream.
@@ -191,7 +191,7 @@
  * @return LY_SUCCESS in case of success
  * @return LY_ERR value in case of failure.
  */
-LY_ERR ly_out_new_file(FILE *f, struct ly_out **out);
+LIBYANG_API_DECL LY_ERR ly_out_new_file(FILE *f, struct ly_out **out);
 
 /**
  * @brief Get or reset file stream printer handler.
@@ -200,7 +200,7 @@
  * @param[in] f Optional new file stream for the handler. If NULL, only the current file stream is returned.
  * @return Previous file stream of the handler. Note that caller is responsible for closing the returned stream in case of setting new stream @p f.
  */
-FILE *ly_out_file(struct ly_out *out, FILE *f);
+LIBYANG_API_DECL FILE *ly_out_file(struct ly_out *out, FILE *f);
 
 /**
  * @brief Create printer handler using memory to dump data.
@@ -213,7 +213,7 @@
  * @return LY_SUCCESS in case of success
  * @return LY_ERR value in case of failure.
  */
-LY_ERR ly_out_new_memory(char **strp, size_t size, struct ly_out **out);
+LIBYANG_API_DECL LY_ERR ly_out_new_memory(char **strp, size_t size, struct ly_out **out);
 
 /**
  * @brief Get or change memory where the data are dumped.
@@ -225,7 +225,7 @@
  * parameter is ignored.
  * @return Previous dumped data. Note that the caller is responsible to free the data in case of changing string pointer @p strp.
  */
-char *ly_out_memory(struct ly_out *out, char **strp, size_t size);
+LIBYANG_API_DECL char *ly_out_memory(struct ly_out *out, char **strp, size_t size);
 
 /**
  * @brief Create printer handler file of the given filename.
@@ -235,7 +235,7 @@
  * @return NULL in case of error.
  * @return Created printer handler supposed to be passed to different ly*_print_*() functions.
  */
-LY_ERR ly_out_new_filepath(const char *filepath, struct ly_out **out);
+LIBYANG_API_DECL LY_ERR ly_out_new_filepath(const char *filepath, struct ly_out **out);
 
 /**
  * @brief Get or change the filepath of the file where the printer prints the data.
@@ -249,7 +249,7 @@
  * @return Previous filepath string in case the @p filepath argument is NULL.
  * @return NULL if changing filepath succeeds and ((void *)-1) otherwise.
  */
-const char *ly_out_filepath(struct ly_out *out, const char *filepath);
+LIBYANG_API_DECL const char *ly_out_filepath(struct ly_out *out, const char *filepath);
 
 /**
  * @brief Generic printer of the given format string into the specified output.
@@ -260,13 +260,13 @@
  * @param[in] format Format string to be printed.
  * @return LY_ERR value, get number of the printed bytes using ::ly_out_printed.
  */
-LY_ERR ly_print(struct ly_out *out, const char *format, ...);
+LIBYANG_API_DECL LY_ERR ly_print(struct ly_out *out, const char *format, ...);
 
 /**
  * @brief Flush the output from any internal buffers and clean any auxiliary data.
  * @param[in] out Output specification.
  */
-void ly_print_flush(struct ly_out *out);
+LIBYANG_API_DECL void ly_print_flush(struct ly_out *out);
 
 /**
  * @brief Generic printer of the given string buffer into the specified output.
@@ -278,7 +278,7 @@
  * @param[in] len Length of the data to print in the @p buf.
  * @return LY_ERR value, get number of the printed bytes using ::ly_out_printed.
  */
-LY_ERR ly_write(struct ly_out *out, const char *buf, size_t len);
+LIBYANG_API_DECL LY_ERR ly_write(struct ly_out *out, const char *buf, size_t len);
 
 /**
  * @brief Get the number of printed bytes by the last function.
@@ -286,7 +286,7 @@
  * @param[in] out Out structure used.
  * @return Number of printed bytes.
  */
-size_t ly_out_printed(const struct ly_out *out);
+LIBYANG_API_DECL size_t ly_out_printed(const struct ly_out *out);
 
 /**
  * @brief Free the printer handler.
@@ -295,7 +295,7 @@
  * @param[in] destroy Flag to free allocated buffer (for LY_OUT_MEMORY) or to
  * close stream/file descriptor (for LY_OUT_FD, LY_OUT_FDSTREAM and LY_OUT_FILE)
  */
-void ly_out_free(struct ly_out *out, void (*clb_arg_destructor)(void *arg), ly_bool destroy);
+LIBYANG_API_DECL void ly_out_free(struct ly_out *out, void (*clb_arg_destructor)(void *arg), ly_bool destroy);
 
 #ifdef __cplusplus
 }