diff --git a/src/buffer.h b/src/buffer.h
@@ -5,16 +5,17 @@
#include <stddef.h>
#include <stdarg.h>
#include <sys/types.h>
+#include "cmark_export.h"
typedef struct {
unsigned char *ptr;
int asize, size;
} cmark_strbuf;
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern unsigned char cmark_strbuf__initbuf[];
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern unsigned char cmark_strbuf__oom[];
#define CMARK_GH_BUF_INIT { cmark_strbuf__initbuf, 0, 0 }
@@ -25,7 +26,7 @@ extern unsigned char cmark_strbuf__oom[];
* For the cases where GH_BUF_INIT cannot be used to do static
* initialization.
*/
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern void cmark_strbuf_init(cmark_strbuf *buf, int initial_size);
/**
@@ -36,7 +37,7 @@ extern void cmark_strbuf_init(cmark_strbuf *buf, int initial_size);
* existing buffer content will be preserved, but calling code must handle
* that buffer was not expanded.
*/
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern int cmark_strbuf_try_grow(cmark_strbuf *buf, int target_size, bool mark_oom);
/**
@@ -52,9 +53,9 @@ static inline int cmark_strbuf_grow(cmark_strbuf *buf, int target_size)
return cmark_strbuf_try_grow(buf, target_size, true);
}
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern void cmark_strbuf_free(cmark_strbuf *buf);
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern void cmark_strbuf_swap(cmark_strbuf *buf_a, cmark_strbuf *buf_b);
/**
@@ -79,14 +80,14 @@ static inline size_t cmark_strbuf_len(const cmark_strbuf *buf)
return buf->size;
}
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern int cmark_strbuf_cmp(const cmark_strbuf *a, const cmark_strbuf *b);
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern void cmark_strbuf_attach(cmark_strbuf *buf, unsigned char *ptr, int asize);
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern unsigned char *cmark_strbuf_detach(cmark_strbuf *buf);
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern void cmark_strbuf_copy_cstr(char *data, int datasize, const cmark_strbuf *buf);
static inline const char *cmark_strbuf_cstr(const cmark_strbuf *buf)
@@ -104,39 +105,39 @@ static inline const char *cmark_strbuf_cstr(const cmark_strbuf *buf)
* return code of these functions and call them in a series then just call
* strbuf_oom at the end.
*/
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern int cmark_strbuf_set(cmark_strbuf *buf, const unsigned char *data, int len);
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern int cmark_strbuf_sets(cmark_strbuf *buf, const char *string);
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern int cmark_strbuf_putc(cmark_strbuf *buf, int c);
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern int cmark_strbuf_put(cmark_strbuf *buf, const unsigned char *data, int len);
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern int cmark_strbuf_puts(cmark_strbuf *buf, const char *string);
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern int cmark_strbuf_printf(cmark_strbuf *buf, const char *format, ...)
__attribute__((format (printf, 2, 3)));
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern int cmark_strbuf_vprintf(cmark_strbuf *buf, const char *format, va_list ap);
-__attribute__((visibility("default")))
+CMARK_EXPORT
extern void cmark_strbuf_clear(cmark_strbuf *buf);
-__attribute__((visibility("default")))
+CMARK_EXPORT
int cmark_strbuf_strchr(const cmark_strbuf *buf, int c, int pos);
-__attribute__((visibility("default")))
+CMARK_EXPORT
int cmark_strbuf_strrchr(const cmark_strbuf *buf, int c, int pos);
-__attribute__((visibility("default")))
+CMARK_EXPORT
void cmark_strbuf_drop(cmark_strbuf *buf, int n);
-__attribute__((visibility("default")))
+CMARK_EXPORT
void cmark_strbuf_truncate(cmark_strbuf *buf, int len);
-__attribute__((visibility("default")))
+CMARK_EXPORT
void cmark_strbuf_rtrim(cmark_strbuf *buf);
-__attribute__((visibility("default")))
+CMARK_EXPORT
void cmark_strbuf_trim(cmark_strbuf *buf);
-__attribute__((visibility("default")))
+CMARK_EXPORT
void cmark_strbuf_normalize_whitespace(cmark_strbuf *s);
-__attribute__((visibility("default")))
+CMARK_EXPORT
void cmark_strbuf_unescape(cmark_strbuf *s);
#ifndef CMARK_NO_SHORT_NAMES
diff --git a/src/cmark.h b/src/cmark.h
@@ -6,6 +6,7 @@
#include "buffer.h"
#include "chunk.h"
#include "references.h"
+#include "cmark_export.h"
#ifdef __cplusplus
extern "C" {
@@ -110,31 +111,31 @@ struct cmark_node_block {
typedef struct cmark_node_block cmark_node_block;
-__attribute__((visibility("default")))
+CMARK_EXPORT
void cmark_free_blocks(cmark_node_block *e);
-__attribute__((visibility("default")))
+CMARK_EXPORT
void cmark_free_inlines(cmark_node_inl* e);
-__attribute__((visibility("default")))
+CMARK_EXPORT
cmark_node_inl* cmark_append_inlines(cmark_node_inl* a, cmark_node_inl* b);
-__attribute__((visibility("default")))
+CMARK_EXPORT
cmark_node_block* cmark_append_blocks(cmark_node_block* a, cmark_node_block* b);
-__attribute__((visibility("default")))
+CMARK_EXPORT
cmark_node_inl *cmark_make_link(cmark_node_inl *label, unsigned char *url, unsigned char *title);
-__attribute__((visibility("default")))
+CMARK_EXPORT
cmark_node_inl* cmark_make_autolink(cmark_node_inl* label, cmark_chunk url, int is_email);
-__attribute__((visibility("default")))
+CMARK_EXPORT
cmark_node_inl* cmark_make_inlines(int t, cmark_node_inl* contents);
-__attribute__((visibility("default")))
+CMARK_EXPORT
cmark_node_inl* cmark_make_literal(int t, cmark_chunk s);
-__attribute__((visibility("default")))
+CMARK_EXPORT
cmark_node_inl* cmark_make_simple(int t);
// Macros for creating various kinds of simple.
@@ -146,19 +147,19 @@ cmark_node_inl* cmark_make_simple(int t);
#define cmark_make_emph(contents) cmark_make_inlines(INL_EMPH, contents)
#define cmark_make_strong(contents) cmark_make_inlines(INL_STRONG, contents)
-__attribute__((visibility("default")))
+CMARK_EXPORT
cmark_node_block *cmark_parse_document(const unsigned char *buffer, size_t len);
-__attribute__((visibility("default")))
+CMARK_EXPORT
cmark_node_block *cmark_parse_file(FILE *f);
-__attribute__((visibility("default")))
+CMARK_EXPORT
void cmark_debug_print(cmark_node_block *root);
-__attribute__((visibility("default")))
+CMARK_EXPORT
void cmark_render_html(cmark_strbuf *html, cmark_node_block *root);
-__attribute__((visibility("default")))
+CMARK_EXPORT
unsigned char *cmark_markdown_to_html(unsigned char *text, int len);
#ifndef CMARK_NO_SHORT_NAMES