Skip to content

Commit cc7e268

Browse files
committed
Use our own handle for EXPORT macro
FCITXCORE_EXPORT & FCITXUTILS_EXPORT will be different when other library reference it. Should handle it ourselves to support windows.
1 parent 03306fa commit cc7e268

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

src/lib/fcitx/addoninstance.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@ class FCITXCORE_EXPORT AddonInstance {
163163
};
164164
} // namespace fcitx
165165

166+
#if defined(_WIN32)
167+
#define FCITX_ADDON_EXPORT __declspec(dllexport)
168+
#else
169+
#define FCITX_ADDON_EXPORT __attribute__((visibility("default")))
170+
#endif
171+
166172
#define FCITX_ADDON_DECLARE_FUNCTION(NAME, FUNCTION, SIGNATURE...) \
167173
namespace fcitx { \
168174
template <> \
@@ -194,15 +200,15 @@ class FCITXCORE_EXPORT AddonInstance {
194200

195201
#define FCITX_ADDON_FACTORY(ClassName) \
196202
extern "C" { \
197-
FCITXCORE_EXPORT ::fcitx::AddonFactory *fcitx_addon_factory_instance() { \
203+
FCITX_ADDON_EXPORT ::fcitx::AddonFactory *fcitx_addon_factory_instance() { \
198204
static ClassName factory; \
199205
return &factory; \
200206
} \
201207
}
202208

203209
#define FCITX_ADDON_FACTORY_V2(AddonName, ClassName) \
204210
extern "C" { \
205-
FCITXCORE_EXPORT ::fcitx::AddonFactory * \
211+
FCITX_ADDON_EXPORT ::fcitx::AddonFactory * \
206212
fcitx_addon_factory_instance_##AddonName() { \
207213
static ClassName factory; \
208214
return &factory; \

test/testemoji.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ int main() {
3737
pathfilter::extension(".dict"));
3838
// Check if all languages are loadable.
3939
for (const auto &[name, __] : files) {
40-
std::string lang = name.stem();
40+
std::string lang = name.stem().string();
4141
FCITX_ASSERT(emoji->call<IEmoji::check>(lang, false))
4242
<< "Failed to load " << lang;
4343
}

test/testlibrary.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,22 @@
66
*/
77

88
#include <string.h>
9-
#include "fcitx-utils/fcitxutils_export.h"
109
#include "fcitx-utils/library.h"
1110
#include "fcitx-utils/log.h"
1211

1312
#define DATA "AAAAAAAAA"
1413
#define MAGIC "MAGIC_TEST_DATA"
1514

15+
#if defined(_WIN32)
16+
#define MY_EXPORT __declspec(dllexport)
17+
#else
18+
#define MY_EXPORT __attribute__((visibility("default")))
19+
#endif
20+
1621
extern "C" {
17-
FCITXUTILS_EXPORT char magic_test[] = MAGIC DATA;
22+
MY_EXPORT char magic_test[] = MAGIC DATA;
1823

19-
FCITXUTILS_EXPORT int func() { return 0; }
24+
MY_EXPORT int func() { return 0; }
2025
}
2126

2227
void parser(const char *data) { FCITX_ASSERT(strcmp(data, DATA) == 0); }

0 commit comments

Comments
 (0)