Skip to content

Commit 69f1f1c

Browse files
committed
as-macros-private.h: Define macros for visibility for clang-cl
On clang-cl (i.e. Visual Studio-like meaning _MSC_VER is defined) builds, symbols in shared builds have visibility to be hidden by default, and decorating symbols with GCC's default visibility is not enough to export the symbol. Consequently, use the macros in as-desktop-entry.h so that we don't fall into the situation where clang-cl complains as we are attempting to do a __declspec(dllexport) in a hidden visibility section.
1 parent acf1575 commit 69f1f1c

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

src/as-desktop-entry.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
#include "as-metadata.h"
2828
#include "as-utils-private.h"
2929

30-
G_BEGIN_DECLS
31-
#pragma GCC visibility push(hidden)
30+
AS_BEGIN_PRIVATE_DECLS
3231

3332
typedef GPtrArray *(*AsTranslateDesktopTextFn) (const GKeyFile *de,
3433
const gchar *text,
@@ -54,7 +53,6 @@ gboolean as_desktop_entry_parse_file (AsComponent *cpt,
5453
gpointer user_data,
5554
GError **error);
5655

57-
#pragma GCC visibility pop
58-
G_END_DECLS
56+
AS_END_PRIVATE_DECLS
5957

6058
#endif /* __AS_DESKTOP_ENTRY_H */

src/as-macros-private.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,20 @@
2626
#include "as-macros.h"
2727

2828
G_BEGIN_DECLS
29+
30+
#ifdef _MSC_VER
31+
32+
#define AS_BEGIN_PRIVATE_DECLS G_BEGIN_DECLS
33+
#define AS_END_PRIVATE_DECLS G_END_DECLS
34+
35+
#ifdef AS_STATIC
36+
# define AS_INTERNAL_VISIBLE
37+
#else
38+
# define AS_INTERNAL_VISIBLE __declspec(dllexport)
39+
#endif
40+
41+
#else
42+
2943
#pragma GCC visibility push(hidden)
3044

3145
#define AS_BEGIN_PRIVATE_DECLS \
@@ -36,6 +50,8 @@ G_BEGIN_DECLS
3650

3751
#define AS_INTERNAL_VISIBLE __attribute__((visibility("default")))
3852

53+
#endif
54+
3955
/**
4056
* as_str_equal0:
4157
* Returns TRUE if strings are equal, ignoring NULL strings.
@@ -107,7 +123,10 @@ G_BEGIN_DECLS
107123
} \
108124
G_STMT_END
109125

126+
#ifndef _MSC_VER
110127
#pragma GCC visibility pop
128+
#endif
129+
111130
G_END_DECLS
112131

113132
#endif /* __AS_MACROS_PRIVATE_H */

0 commit comments

Comments
 (0)