diff --git a/include/discord-rpc.h b/include/discord-rpc.h index ba639c9..3db5ad9 100644 --- a/include/discord-rpc.h +++ b/include/discord-rpc.h @@ -14,7 +14,7 @@ # define DISCORD_EXPORT __attribute__((visibility("default"))) # endif #else -# define DISCORD_EXPORT +# define DISCORD_EXPORT #endif // clang-format on @@ -64,14 +64,14 @@ DISCORD_EXPORT void Discord_Initialize(const char* applicationId, DiscordEventHandlers* handlers, int autoRegister, const char* optionalSteamId); -DISCORD_EXPORT void Discord_Shutdown(); +DISCORD_EXPORT void Discord_Shutdown(void); /* checks for incoming messages, dispatches callbacks */ -DISCORD_EXPORT void Discord_RunCallbacks(); +DISCORD_EXPORT void Discord_RunCallbacks(void); /* If you disable the lib starting its own io thread, you'll need to call this from your own */ #ifdef DISCORD_DISABLE_IO_THREAD -DISCORD_EXPORT void Discord_UpdateConnection(); +DISCORD_EXPORT void Discord_UpdateConnection(void); #endif DISCORD_EXPORT void Discord_UpdatePresence(const DiscordRichPresence* presence); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cca36e6..39f1275 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -44,7 +44,7 @@ endif(WIN32) if(UNIX) set(BASE_RPC_SRC ${BASE_RPC_SRC} connection_unix.cpp) - + if (APPLE) add_definitions(-DDISCORD_OSX) set(BASE_RPC_SRC ${BASE_RPC_SRC} discord_register_osx.m) @@ -55,7 +55,19 @@ if(UNIX) add_library(discord-rpc ${RPC_LIBRARY_TYPE} ${BASE_RPC_SRC}) target_link_libraries(discord-rpc PUBLIC pthread) - target_compile_options(discord-rpc PRIVATE -g -Wall) + target_compile_options(discord-rpc PRIVATE + -g + -Weverything + -Wno-unknown-pragmas # pragma push thing doesn't work on clang + -Wno-old-style-cast # it's fine + -Wno-c++98-compat # that was almost 2 decades ago + -Wno-c++98-compat-pedantic + -Wno-missing-noreturn + -Wno-padded # structure padding + -Wno-covered-switch-default + -Wno-exit-time-destructors # not sure about these + -Wno-global-constructors + ) target_compile_options(discord-rpc PRIVATE $<$:-std=c++14>) if (APPLE) diff --git a/src/connection_unix.cpp b/src/connection_unix.cpp index a201b60..6fe359e 100644 --- a/src/connection_unix.cpp +++ b/src/connection_unix.cpp @@ -111,7 +111,7 @@ bool BaseConnection::Read(void* data, size_t length) return false; } - int res = recv(self->sock, data, length, MsgFlags); + int res = (int)recv(self->sock, data, length, MsgFlags); if (res < 0) { if (errno == EAGAIN) { return false; diff --git a/src/discord-rpc.cpp b/src/discord-rpc.cpp index e5f44f2..b5c112f 100644 --- a/src/discord-rpc.cpp +++ b/src/discord-rpc.cpp @@ -47,8 +47,8 @@ static int LastDisconnectErrorCode{0}; static char LastDisconnectErrorMessage[256]; static std::mutex PresenceMutex; static QueuedMessage QueuedPresence{}; -MsgQueue SendQueue; -MsgQueue JoinAskQueue; +static MsgQueue SendQueue; +static MsgQueue JoinAskQueue; // We want to auto connect, and retry on failure, but not as fast as possible. This does expoential // backoff from 0.5 seconds to 1 minute @@ -70,7 +70,11 @@ static void UpdateReconnectTime() std::chrono::duration{ReconnectTimeMs.nextDelay()}; } -DISCORD_EXPORT void Discord_UpdateConnection() +#ifdef DISCORD_DISABLE_IO_THREAD +DISCORD_EXPORT void Discord_UpdateConnection(void) +#else +static void Discord_UpdateConnection(void) +#endif { if (!Connection) { return; @@ -173,7 +177,7 @@ DISCORD_EXPORT void Discord_UpdateConnection() } #ifndef DISCORD_DISABLE_IO_THREAD -void DiscordRpcIo() +static void DiscordRpcIo(void) { const std::chrono::duration maxWait{500LL}; @@ -186,14 +190,14 @@ void DiscordRpcIo() } #endif -void SignalIOActivity() +static void SignalIOActivity() { #ifndef DISCORD_DISABLE_IO_THREAD WaitForIOActivity.notify_all(); #endif } -bool RegisterForEvent(const char* evtName) +static bool RegisterForEvent(const char* evtName) { auto qmessage = SendQueue.GetNextAddMessage(); if (qmessage) { diff --git a/src/discord_register.h b/src/discord_register.h index 876b307..4eb3c3c 100644 --- a/src/discord_register.h +++ b/src/discord_register.h @@ -9,4 +9,4 @@ void Discord_RegisterSteamGame(const char* applicationId, const char* steamId); #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/src/discord_register_osx.m b/src/discord_register_osx.m index 1951b9a..20063e7 100644 --- a/src/discord_register_osx.m +++ b/src/discord_register_osx.m @@ -3,6 +3,8 @@ #import +#include "discord_register.h" + static bool Mkdir(const char* path) { int result = mkdir(path, 0755); @@ -39,7 +41,7 @@ static void RegisterCommand(const char* applicationId, const char* command) if (f) { char jsonBuffer[2048]; int len = snprintf(jsonBuffer, sizeof(jsonBuffer), "{\"command\": \"%s\"}", command); - fwrite(jsonBuffer, len, 1, f); + fwrite(jsonBuffer, (size_t)len, 1, f); fclose(f); } } diff --git a/src/msg_queue.h b/src/msg_queue.h index c510b2e..65eb4da 100644 --- a/src/msg_queue.h +++ b/src/msg_queue.h @@ -13,7 +13,7 @@ class MsgQueue { std::atomic_uint pendingSends_{0}; public: - MsgQueue(){}; + MsgQueue(){} ElementType* GetNextAddMessage() { diff --git a/src/serialization.cpp b/src/serialization.cpp index fd281f1..f416840 100644 --- a/src/serialization.cpp +++ b/src/serialization.cpp @@ -72,7 +72,7 @@ void WriteOptionalString(JsonWriter& w, T& k, const char* value) } } -void JsonWriteNonce(JsonWriter& writer, int nonce) +static void JsonWriteNonce(JsonWriter& writer, int nonce) { WriteKey(writer, "nonce"); char nonceBuffer[32];