diff options
-rw-r--r-- | includes/BString.h | 10 | ||||
-rw-r--r-- | src/HttpServer.cc | 2 | ||||
-rw-r--r-- | tests/test-Handles.cc | 4 |
3 files changed, 9 insertions, 7 deletions
diff --git a/includes/BString.h b/includes/BString.h index 09e0d40..f8f9710 100644 --- a/includes/BString.h +++ b/includes/BString.h @@ -1,5 +1,7 @@ #pragma once +#define __STDC_FORMAT_MACROS +#include <inttypes.h> #include <stdarg.h> #include <string.h> #include <stdint.h> @@ -20,10 +22,10 @@ class String : private std::string { String(const char (&str)[L]) : std::string(str, L - 1) { } String(const char * str, size_t n) : std::string(str ? str : "", str ? n : 0) { } String(char c) { set("%c", c); } - String(int32_t i) { set("%i", i); } - String(uint32_t i) { set("%u", i); } - String(int64_t i) { set("%lli", i); } - String(uint64_t i) { set("%llu", i); } + String(int32_t i) { set("%" PRIi32, i); } + String(uint32_t i) { set("%" PRIu32, i); } + String(int64_t i) { set("%" PRIi64, i); } + String(uint64_t i) { set("%" PRIu64, i); } String(double d) { set("%g", d); } String(const String & s) : std::string(s) { } String(const std::string & s) : std::string(s) { } diff --git a/src/HttpServer.cc b/src/HttpServer.cc index 23af486..357bb26 100644 --- a/src/HttpServer.cc +++ b/src/HttpServer.cc @@ -221,7 +221,7 @@ void Balau::HttpWorker::sendError(int error, const char * msg, const char * deta "Content-Type: text/html; charset=UTF-8\r\n" "Connection: keep-alive\r\n" "Server: %s\r\n" -"Content-Length: %lli\r\n", +"Content-Length: %" PRIu64 "\r\n", error, errorMsg, m_server->getServerName().to_charp(), length); for (String & str : extraHeaders) headers += str + "\r\n"; diff --git a/tests/test-Handles.cc b/tests/test-Handles.cc index d64fe9b..847cb24 100644 --- a/tests/test-Handles.cc +++ b/tests/test-Handles.cc @@ -30,7 +30,7 @@ void MainTask::Do() { TAssert(failed); IO<Handle> i(new Input("tests/rtest.txt")); Printer::log(M_STATUS, "Opened file %s:", i->getName()); - Printer::log(M_STATUS, " - size = %lli", i->getSize()); + Printer::log(M_STATUS, " - size = %" PRIi64, i->getSize()); char mtimestr[32]; time_t mtime = i->getMTime(); @@ -50,7 +50,7 @@ void MainTask::Do() { i->rseek(0, SEEK_SET); char * buf1 = (char *) malloc(i->getSize()); ssize_t r = i->read(buf1, s + 15); - Printer::log(M_STATUS, "Read %zi bytes (instead of %lli)", r, s + 15); + Printer::log(M_STATUS, "Read %zi bytes (instead of %" PRIi64 ")", r, s + 15); TAssert(i->isEOF()) char * buf2 = (char *) malloc(i->getSize()); |