From 15cb4261665bab4ef02a5b1b9db48b9477c9b87a Mon Sep 17 00:00:00 2001 From: iphydf Date: Sun, 18 Sep 2016 01:31:55 +0100 Subject: Make toxcore code C++ compatible. It is still C code, so still compatible with C compilers as well. This change lets us see more clearly where implicit conversions occur by making them explicit. --- toxcore/tox.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'toxcore/tox.c') diff --git a/toxcore/tox.c b/toxcore/tox.c index 93993c53..bf664b41 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c @@ -158,7 +158,7 @@ void tox_options_default(struct Tox_Options *options) struct Tox_Options *tox_options_new(TOX_ERR_OPTIONS_NEW *error) { - struct Tox_Options *options = calloc(sizeof(struct Tox_Options), 1); + struct Tox_Options *options = (struct Tox_Options *)calloc(sizeof(struct Tox_Options), 1); if (options) { tox_options_default(options); @@ -303,7 +303,7 @@ void tox_kill(Tox *tox) Messenger *m = tox; Logger *log = m->log; - kill_groupchats(m->group_chat_object); + kill_groupchats((Group_Chats *)m->group_chat_object); kill_messenger(m); logger_kill(log); } @@ -463,7 +463,7 @@ TOX_CONNECTION tox_self_get_connection_status(const Tox *tox) void tox_callback_self_connection_status(Tox *tox, tox_self_connection_status_cb *callback) { Messenger *m = tox; - m_callback_core_connection(m, callback); + m_callback_core_connection(m, (void (*)(Messenger *, unsigned int, void *))callback); } uint32_t tox_iteration_interval(const Tox *tox) @@ -476,7 +476,7 @@ void tox_iterate(Tox *tox, void *user_data) { Messenger *m = tox; do_messenger(m, user_data); - do_groupchats(m->group_chat_object, user_data); + do_groupchats((Group_Chats *)m->group_chat_object, user_data); } void tox_self_get_address(const Tox *tox, uint8_t *address) @@ -528,7 +528,7 @@ bool tox_self_set_name(Tox *tox, const uint8_t *name, size_t length, TOX_ERR_SET if (setname(m, name, length) == 0) { // TODO(irungentoo): function to set different per group names? - send_name_all_groups(m->group_chat_object); + send_name_all_groups((Group_Chats *)m->group_chat_object); SET_ERROR_PARAMETER(error, TOX_ERR_SET_INFO_OK); return 1; } @@ -592,7 +592,7 @@ void tox_self_set_status(Tox *tox, TOX_USER_STATUS status) TOX_USER_STATUS tox_self_get_status(const Tox *tox) { const Messenger *m = tox; - return m_get_self_userstatus(m); + return (TOX_USER_STATUS)m_get_self_userstatus(m); } static void set_friend_error(int32_t ret, TOX_ERR_FRIEND_ADD *error) @@ -842,17 +842,17 @@ TOX_USER_STATUS tox_friend_get_status(const Tox *tox, uint32_t friend_number, TO if (ret == USERSTATUS_INVALID) { SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_QUERY_FRIEND_NOT_FOUND); - return TOX_USER_STATUS_BUSY + 1; + return (TOX_USER_STATUS)(TOX_USER_STATUS_BUSY + 1); } SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_QUERY_OK); - return ret; + return (TOX_USER_STATUS)ret; } void tox_callback_friend_status(Tox *tox, tox_friend_status_cb *callback) { Messenger *m = tox; - m_callback_userstatus(m, callback); + m_callback_userstatus(m, (void (*)(Messenger *, uint32_t, unsigned int, void *))callback); } TOX_CONNECTION tox_friend_get_connection_status(const Tox *tox, uint32_t friend_number, TOX_ERR_FRIEND_QUERY *error) @@ -867,13 +867,13 @@ TOX_CONNECTION tox_friend_get_connection_status(const Tox *tox, uint32_t friend_ } SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_QUERY_OK); - return ret; + return (TOX_CONNECTION)ret; } void tox_callback_friend_connection_status(Tox *tox, tox_friend_connection_status_cb *callback) { Messenger *m = tox; - m_callback_connectionstatus(m, callback); + m_callback_connectionstatus(m, (void (*)(Messenger *, uint32_t, unsigned int, void *))callback); } bool tox_friend_get_typing(const Tox *tox, uint32_t friend_number, TOX_ERR_FRIEND_QUERY *error) @@ -972,7 +972,7 @@ void tox_callback_friend_request(Tox *tox, tox_friend_request_cb *callback) void tox_callback_friend_message(Tox *tox, tox_friend_message_cb *callback) { Messenger *m = tox; - m_callback_friendmessage(m, callback); + m_callback_friendmessage(m, (void (*)(Messenger *, uint32_t, unsigned int, const uint8_t *, size_t, void *))callback); } bool tox_hash(uint8_t *hash, const uint8_t *data, size_t length) @@ -1079,7 +1079,7 @@ bool tox_file_seek(Tox *tox, uint32_t friend_number, uint32_t file_number, uint6 void tox_callback_file_recv_control(Tox *tox, tox_file_recv_control_cb *callback) { Messenger *m = tox; - callback_file_control(m, callback); + callback_file_control(m, (void (*)(Messenger *, uint32_t, uint32_t, unsigned int, void *))callback); } bool tox_file_get_file_id(const Tox *tox, uint32_t friend_number, uint32_t file_number, uint8_t *file_id, -- cgit v1.2.3