Use fct attr used to preserve key_control syms

This prevents them from being removed by linker with the modular build.
This commit is contained in:
Martin Pulec
2019-11-01 08:50:24 +01:00
parent 6257703d9a
commit ff0fb6a310
3 changed files with 10 additions and 10 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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_