Fix compatibility with GCC

This commit is contained in:
blankie 2023-06-21 18:45:08 +07:00
parent eca77cbec0
commit 4f5219bbbe
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
11 changed files with 23 additions and 10 deletions

View File

@ -37,7 +37,7 @@ endif()
# https://t.me/NightShadowsHangout/670691
# https://t.me/NightShadowsHangout/688372
list(APPEND FLAGS -Werror -Wall -Wextra -Wshadow -Wpedantic -Wno-gnu-anonymous-struct -fPIC -Wconversion -Wno-unused-parameter -Wimplicit-fallthrough)
list(APPEND FLAGS -Werror -Wall -Wextra -Wshadow -Wpedantic -Wno-gnu-anonymous-struct -fPIC -Wconversion -Wno-unused-parameter -Wimplicit-fallthrough -Wno-missing-field-initializers)
# i have no idea why this hack wasn't needed before but it's needed if sanitizers are used
add_link_options(${FLAGS})

4
file.h
View File

@ -15,7 +15,7 @@ public:
File(const File&) = delete;
File& operator=(const File&) = delete;
inline constexpr File(File&& other) {
inline File(File&& other) {
try_close(this->_file);
this->_file = other._file;
other._file = nullptr;
@ -47,7 +47,7 @@ public:
throw_system_error("fwrite()");
}
}
inline constexpr void write(const std::string& str) {
inline void write(const std::string& str) {
this->write(str.data(), str.size());
}
inline constexpr FILE* get() const noexcept {

View File

@ -105,7 +105,7 @@ static inline std::optional<File> save_file_picker() {
try {
File file(path, "w");
NFD_FreePath(path);
return std::move(file);
return file;
} catch (const std::exception& e) {
NFD_FreePath(path);
log(std::string("Failed to open file from file picker: ") + e.what());

View File

@ -139,7 +139,7 @@ static inline std::optional<File> open_file_picker() {
try {
File file(path, "r");
NFD_FreePath(path);
return std::move(file);
return file;
} catch (const std::exception& e) {
NFD_FreePath(path);
log(std::string("Failed to open file from file picker: ") + e.what());

View File

@ -1,6 +1,9 @@
#define IMGUI_DEFINE_MATH_OPERATORS
#include <imgui/imgui.h>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <imgui/imgui_internal.h>
#pragma GCC diagnostic pop
#include "group_panel.h"
// The following code is slightly modified public domain code from https://github.com/thedmd

View File

@ -6,10 +6,10 @@
std::vector<LogEntry> log_entries;
LogEntry::LogEntry(time_t time, std::string message_) : message(std::move(message_)) {
LogEntry::LogEntry(time_t time_, std::string message_) : message(std::move(message_)) {
size_t pos;
localtime_r(&time, &this->time);
localtime_r(&time_, &this->time);
while ((pos = this->message.find('\n')) != std::string::npos) {
this->message.replace(pos, 1, 1, ' ');
}

2
log.h
View File

@ -9,7 +9,7 @@ struct LogEntry {
std::string message;
LogEntry() = default;
LogEntry(time_t time, std::string message_);
LogEntry(time_t time_, std::string message_);
};
extern std::vector<LogEntry> log_entries;

View File

@ -36,6 +36,7 @@ const char* to_string(Priority priority) {
case Priority::Fatal: return "Fatal";
case Priority::Unknown: return "Unknown";
}
return "Unknown??";
}
const char* to_string(Buffer buffer) {
@ -47,6 +48,7 @@ const char* to_string(Buffer buffer) {
case Buffer::Crash: return "Crash";
case Buffer::Unknown: return "Unknown";
}
return "Unknown??";
}
const char* to_string_lower(Buffer buffer) {
@ -58,6 +60,7 @@ const char* to_string_lower(Buffer buffer) {
case Buffer::Crash: return "crash";
case Buffer::Unknown: return "unknown";
}
return "Unknown??";
}
std::string to_string(const LogcatEntry& logcat_entry) {
@ -127,7 +130,7 @@ std::optional<LogcatEntry> try_parse_logcat_entry(char* buf, size_t length, Buff
localtime_r(&time, &logcat_entry.time);
}
return std::move(logcat_entry);
return logcat_entry;
}
std::optional<Buffer> try_parse_buffer(char* buf, size_t length) {
@ -234,6 +237,7 @@ static inline char to_char(Priority priority) {
case Priority::Fatal: return 'F';
case Priority::Unknown: return 'U';
}
return 'U';
}
static inline std::string rightpad(const std::string& str, size_t characters) {

View File

@ -2,7 +2,10 @@
#include <sstream>
#include <system_error>
#include <imgui/imgui.h>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <imgui/imgui_internal.h>
#pragma GCC diagnostic pop
#include "misc.h"

View File

@ -1,4 +1,4 @@
#include <imgui/imgui.cpp>
#include <imgui/imgui.h>
#include "../myimconfig.h"
#include "../log.h"

View File

@ -1,5 +1,8 @@
#include <imgui/imgui.h>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <imgui/imgui_internal.h>
#pragma GCC diagnostic pop
#include <ctime>
#include <string>
#include <vector>