Skip to content

Commit 3780d73

Browse files
authored
build: correct export decoration macros (#38)
This corrects the attribute for the export and import handling on Windows. It takes the opportunity to do a small optimization for Linux to avoid the GOT in internal dispatch.
1 parent fce0dee commit 3780d73

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/include/cmark-gfm_export.h

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,24 @@
66
# define CMARK_GFM_EXPORT
77
# define CMARK_GFM_NO_EXPORT
88
#else
9-
# ifndef CMARK_GFM_EXPORT
10-
# ifdef libcmark_gfm_EXPORTS
11-
/* We are building this library */
12-
# define CMARK_GFM_EXPORT __attribute__((visibility("default")))
9+
# if defined(_WIN32)
10+
# if defined(libcmark_gfm_EXPORTS)
11+
# define CMARK_GFM_EXPORT __declspec(dllexport)
1312
# else
14-
/* We are using this library */
15-
# define CMARK_GFM_EXPORT __attribute__((visibility("default")))
13+
# define CMARK_GFM_EXPORT __declspec(dllimport)
1614
# endif
17-
# endif
18-
19-
# ifndef CMARK_GFM_NO_EXPORT
20-
# define CMARK_GFM_NO_EXPORT __attribute__((visibility("hidden")))
15+
# define CMARK_GFM_NO_EXPORT
16+
# else
17+
# if defined(libcmark_gfm_EXPORTS)
18+
# if defined(__linux__)
19+
# define CMARK_GFM_EXPORT __attribute__((__visibility__("protected")))
20+
# else
21+
# define CMARK_GFM_EXPORT __attribute__((__visibility__("default")))
22+
# endif
23+
# else
24+
# define CMARK_GFM_EXPORT __attribute__((__visibility__("default")))
25+
# endif
26+
# define CMARK_GFM_NO_EXPORT __attribute__((__visibility__("hidden")))
2127
# endif
2228
#endif
2329

0 commit comments

Comments
 (0)