diff --git a/src/host.h b/src/host.h index 156495cbe..5957a12af 100644 --- a/src/host.h +++ b/src/host.h @@ -199,4 +199,10 @@ struct NOT_DEFINED_STRUCT_THAT_SWALLOWS_SEMICOLON #define OPTIMIZED_FOR for #endif +#ifdef __cplusplus +#define EXTERN_C extern "C" +#else +#define EXTERN_C +#endif + #endif diff --git a/src/keyboard_control.cpp b/src/keyboard_control.cpp index 6f6354b86..e674812ff 100644 --- a/src/keyboard_control.cpp +++ b/src/keyboard_control.cpp @@ -846,12 +846,6 @@ void keyboard_control::msg_received() { } } -#define FORCE_UNDEFINED_SYMBOL(x) void* __ ## x ## _fp =(void*)&x; -/** - * This needs to be in uv executable to be able to provide it to GL/SDL - * display modules (modular build) therefore FORCE_UNDEFINED_SYMBOL is used - * @todo Find a systematic solution - */ void keycontrol_send_key(struct module *root, int64_t key) { struct msg_universal *m = (struct msg_universal *) new_message(sizeof(struct msg_universal)); sprintf(m->text, "press %" PRId64, key); @@ -861,7 +855,6 @@ void keycontrol_send_key(struct module *root, int64_t key) { } free_response(r); } -FORCE_UNDEFINED_SYMBOL(keycontrol_send_key) /** @brief Registers callback message for given key * @@ -888,5 +881,4 @@ bool keycontrol_register_key(struct module *receiver_mod, int64_t key, const cha free_response(r); return true; } -FORCE_UNDEFINED_SYMBOL(keycontrol_register_key) diff --git a/src/keyboard_control.h b/src/keyboard_control.h index 600b7e1b2..bf54438f3 100644 --- a/src/keyboard_control.h +++ b/src/keyboard_control.h @@ -106,8 +106,10 @@ private: std::mutex m_lock; }; -extern "C" void keycontrol_send_key(struct module *root, int64_t key); -extern "C" bool keycontrol_register_key(struct module *sender_mod, int64_t key, const char *message, const char *description); +// attribute used guaranties that the symbol is present even if not referenced (modular build) +/// @todo all UG core functions should have the 'used' attribute +EXTERN_C void keycontrol_send_key(struct module *root, int64_t key) ATTRIBUTE(used); +EXTERN_C bool keycontrol_register_key(struct module *sender_mod, int64_t key, const char *message, const char *description) ATTRIBUTE(used); #endif // keyboard_control_h_