diff --git a/CMakeLists.txt b/CMakeLists.txt index 8c19c125a..ab51026f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -145,6 +145,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES GNU) if (WIN32) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static") + add_definitions(/D__STDC_FORMAT_MACROS) else() set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++") endif() diff --git a/src/net/Client.cpp b/src/net/Client.cpp index b9ef5fd3e..953dde4ce 100644 --- a/src/net/Client.cpp +++ b/src/net/Client.cpp @@ -21,12 +21,11 @@ * along with this program. If not, see . */ - +#include #include #include #include - #include "log/Log.h" #include "interfaces/IClientListener.h" #include "net/Client.h" @@ -172,7 +171,7 @@ int64_t Client::submit(const JobResult &result) data[64] = '\0'; # endif - snprintf(req, 345, "{\"id\":%llu,\"jsonrpc\":\"2.0\",\"method\":\"submit\",\"params\":{\"id\":\"%s\",\"job_id\":\"%s\",\"nonce\":\"%s\",\"result\":\"%s\"}}\n", + snprintf(req, 345, "{\"id\":%" PRIu64 ",\"jsonrpc\":\"2.0\",\"method\":\"submit\",\"params\":{\"id\":\"%s\",\"job_id\":\"%s\",\"nonce\":\"%s\",\"result\":\"%s\"}}\n", m_sequence, m_rpcId, result.jobId, nonce, data); m_results[m_sequence] = SubmitResult(m_sequence, result.diff); @@ -344,7 +343,7 @@ void Client::parseNotification(const char *method, const json_t *params, const j { if (json_is_object(error)) { if (!m_quiet) { - LOG_ERR("[%s:%u] error: \"%s\", code: %lld", m_url.host(), m_url.port(), json_string_value(json_object_get(error, "message")), json_integer_value(json_object_get(error, "code"))); + LOG_ERR("[%s:%u] error: \"%s\", code: %" PRId64, m_url.host(), m_url.port(), json_string_value(json_object_get(error, "message")), json_integer_value(json_object_get(error, "code"))); } return; } @@ -377,7 +376,7 @@ void Client::parseResponse(int64_t id, const json_t *result, const json_t *error m_results.erase(it); } else if (!m_quiet) { - LOG_ERR("[%s:%u] error: \"%s\", code: %lld", m_url.host(), m_url.port(), message, json_integer_value(json_object_get(error, "code"))); + LOG_ERR("[%s:%u] error: \"%s\", code: %" PRId64, m_url.host(), m_url.port(), message, json_integer_value(json_object_get(error, "code"))); } if (id == 1 || (message && strncasecmp(message, "Unauthenticated", 15) == 0)) { @@ -418,7 +417,7 @@ void Client::parseResponse(int64_t id, const json_t *result, const json_t *error void Client::ping() { char *req = static_cast(malloc(128)); - snprintf(req, 128, "{\"id\":%lld,\"jsonrpc\":\"2.0\",\"method\":\"keepalived\",\"params\":{\"id\":\"%s\"}}\n", m_sequence, m_rpcId); + snprintf(req, 128, "{\"id\":%" PRId64 ",\"jsonrpc\":\"2.0\",\"method\":\"keepalived\",\"params\":{\"id\":\"%s\"}}\n", m_sequence, m_rpcId); send(req); } diff --git a/src/net/Network.cpp b/src/net/Network.cpp index ee8d7b3ea..59ce83d75 100644 --- a/src/net/Network.cpp +++ b/src/net/Network.cpp @@ -22,6 +22,7 @@ */ +#include #include #include @@ -137,12 +138,16 @@ void Network::onResultAccepted(Client *client, int64_t seq, uint32_t diff, uint6 if (error) { m_rejected++; - LOG_INFO(m_options->colors() ? "\x1B[01;31mrejected\x1B[0m (%lld/%lld) diff \x1B[01;37m%u\x1B[0m \x1B[31m\"%s\"\x1B[0m \x1B[01;30m(%llu ms)" : "rejected (%lld/%lld) diff %u \"%s\" (%llu ms)", m_accepted, m_rejected, diff, error, ms); + LOG_INFO(m_options->colors() ? "\x1B[01;31mrejected\x1B[0m (%" PRId64 "/%" PRId64 ") diff \x1B[01;37m%u\x1B[0m \x1B[31m\"%s\"\x1B[0m \x1B[01;30m(%" PRIu64 " ms)" + : "rejected (%" PRId64 "/%" PRId64 ") diff %u \"%s\" (%" PRIu64 " ms)", + m_accepted, m_rejected, diff, error, ms); } else { m_accepted++; - LOG_INFO(m_options->colors() ? "\x1B[01;32maccepted\x1B[0m (%lld/%lld) diff \x1B[01;37m%u\x1B[0m \x1B[01;30m(%llu ms)" : "accepted (%lld/%lld) diff %u (%llu ms)", m_accepted, m_rejected, diff, ms); + LOG_INFO(m_options->colors() ? "\x1B[01;32maccepted\x1B[0m (%" PRId64 "/%" PRId64 ") diff \x1B[01;37m%u\x1B[0m \x1B[01;30m(%" PRIu64 " ms)" + : "accepted (%" PRId64 "/%" PRId64 ") diff %u (%" PRIu64 " ms)", + m_accepted, m_rejected, diff, ms); } }