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/tree_data_free.c b/src/tree_data_free.c
index cf70bf7..88c3b34 100644
--- a/src/tree_data_free.c
+++ b/src/tree_data_free.c
@@ -67,13 +67,13 @@
}
}
-API void
+LIBYANG_API_DEF void
lyd_free_meta_single(struct lyd_meta *meta)
{
lyd_free_meta(meta, 0);
}
-API void
+LIBYANG_API_DEF void
lyd_free_meta_siblings(struct lyd_meta *meta)
{
lyd_free_meta(meta, 1);
@@ -125,13 +125,13 @@
}
}
-API void
+LIBYANG_API_DEF void
lyd_free_attr_single(const struct ly_ctx *ctx, struct lyd_attr *attr)
{
lyd_free_attr(ctx, attr, 0);
}
-API void
+LIBYANG_API_DEF void
lyd_free_attr_siblings(const struct ly_ctx *ctx, struct lyd_attr *attr)
{
lyd_free_attr(ctx, attr, 1);
@@ -194,7 +194,7 @@
free(node);
}
-API void
+LIBYANG_API_DEF void
lyd_free_tree(struct lyd_node *node)
{
if (!node) {
@@ -227,13 +227,13 @@
}
}
-API void
+LIBYANG_API_DEF void
lyd_free_siblings(struct lyd_node *node)
{
lyd_free_(node, 0);
}
-API void
+LIBYANG_API_DEF void
lyd_free_all(struct lyd_node *node)
{
lyd_free_(node, 1);