From 9b6dfa793dacc774d17c27658046857fed325ee9 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 24 Nov 2023 07:57:48 +0100 Subject: Fix build on 32-bit systems --- build.sh | 8 ++++---- src/config.hpp | 20 ++++++++++++-------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/build.sh b/build.sh index eb03141..9bbb02e 100755 --- a/build.sh +++ b/build.sh @@ -18,12 +18,12 @@ build_gsr_gtk() { dependencies="gtk+-3.0 x11 xrandr libpulse libdrm wayland-egl wayland-client" includes="$(pkg-config --cflags $dependencies)" libs="$(pkg-config --libs $dependencies) -ldl" - gcc -c src/egl.c $opts $includes + $CC -c src/egl.c $opts $includes $CC -c external/wlr-export-dmabuf-unstable-v1-protocol.c $opts $includes - g++ -c src/main.cpp $opts $includes - g++ -o gpu-screen-recorder-gtk egl.o wlr-export-dmabuf-unstable-v1-protocol.o main.o $libs $opts + $CXX -c src/main.cpp $opts $includes + $CXX -o gpu-screen-recorder-gtk egl.o wlr-export-dmabuf-unstable-v1-protocol.o main.o $libs $opts } build_wayland_protocol build_gsr_gtk -echo "Successfully built gpu-screen-recorder-gtk" \ No newline at end of file +echo "Successfully built gpu-screen-recorder-gtk" diff --git a/src/config.hpp b/src/config.hpp index be3fbf3..20614aa 100644 --- a/src/config.hpp +++ b/src/config.hpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -213,6 +214,9 @@ static bool string_to_int(std::string str, int &value) { return true; } +#define FORMAT_I64 "%" PRIi64 +#define FORMAT_U32 "%" PRIu32 + static Config read_config(bool &config_empty) { Config config; @@ -279,7 +283,7 @@ static Config read_config(bool &config_empty) { config.streaming_config.stream_key.assign(value.str, value.size); } else if(key == "streaming.start_recording_hotkey") { std::string value_str(value.str, value.size); - if(sscanf(value_str.c_str(), "%ld %u", &config.streaming_config.start_recording_hotkey.keysym, &config.streaming_config.start_recording_hotkey.modifiers) != 2) { + if(sscanf(value_str.c_str(), FORMAT_I64 " " FORMAT_U32, &config.streaming_config.start_recording_hotkey.keysym, &config.streaming_config.start_recording_hotkey.modifiers) != 2) { fprintf(stderr, "Warning: Invalid config option value for streaming.start_recording_hotkey\n"); config.streaming_config.start_recording_hotkey.keysym = 0; config.streaming_config.start_recording_hotkey.modifiers = 0; @@ -290,7 +294,7 @@ static Config read_config(bool &config_empty) { config.record_config.container.assign(value.str, value.size); } else if(key == "record.start_recording_hotkey") { std::string value_str(value.str, value.size); - if(sscanf(value_str.c_str(), "%ld %u", &config.record_config.start_recording_hotkey.keysym, &config.record_config.start_recording_hotkey.modifiers) != 2) { + if(sscanf(value_str.c_str(), FORMAT_I64 " " FORMAT_U32, &config.record_config.start_recording_hotkey.keysym, &config.record_config.start_recording_hotkey.modifiers) != 2) { fprintf(stderr, "Warning: Invalid config option value for record.start_recording_hotkey\n"); config.record_config.start_recording_hotkey.keysym = 0; config.record_config.start_recording_hotkey.modifiers = 0; @@ -306,14 +310,14 @@ static Config read_config(bool &config_empty) { } } else if(key == "replay.start_recording_hotkey") { std::string value_str(value.str, value.size); - if(sscanf(value_str.c_str(), "%ld %u", &config.replay_config.start_recording_hotkey.keysym, &config.replay_config.start_recording_hotkey.modifiers) != 2) { + if(sscanf(value_str.c_str(), FORMAT_I64 " " FORMAT_U32, &config.replay_config.start_recording_hotkey.keysym, &config.replay_config.start_recording_hotkey.modifiers) != 2) { fprintf(stderr, "Warning: Invalid config option value for replay.start_recording_hotkey\n"); config.replay_config.start_recording_hotkey.keysym = 0; config.replay_config.start_recording_hotkey.modifiers = 0; } } else if(key == "replay.save_recording_hotkey") { std::string value_str(value.str, value.size); - if(sscanf(value_str.c_str(), "%ld %u", &config.replay_config.save_recording_hotkey.keysym, &config.replay_config.save_recording_hotkey.modifiers) != 2) { + if(sscanf(value_str.c_str(), FORMAT_I64 " " FORMAT_U32, &config.replay_config.save_recording_hotkey.keysym, &config.replay_config.save_recording_hotkey.modifiers) != 2) { fprintf(stderr, "Warning: Invalid config option value for replay.save_recording_hotkey\n"); config.replay_config.save_recording_hotkey.keysym = 0; config.replay_config.save_recording_hotkey.modifiers = 0; @@ -363,17 +367,17 @@ static void save_config(const Config &config) { fprintf(file, "streaming.service %s\n", config.streaming_config.streaming_service.c_str()); fprintf(file, "streaming.key %s\n", config.streaming_config.stream_key.c_str()); - fprintf(file, "streaming.start_recording_hotkey %ld %u\n", config.streaming_config.start_recording_hotkey.keysym, config.streaming_config.start_recording_hotkey.modifiers); + fprintf(file, "streaming.start_recording_hotkey " FORMAT_I64 " " FORMAT_U32 "\n", config.streaming_config.start_recording_hotkey.keysym, config.streaming_config.start_recording_hotkey.modifiers); fprintf(file, "record.save_directory %s\n", config.record_config.save_directory.c_str()); fprintf(file, "record.container %s\n", config.record_config.container.c_str()); - fprintf(file, "record.start_recording_hotkey %ld %u\n", config.record_config.start_recording_hotkey.keysym, config.record_config.start_recording_hotkey.modifiers); + fprintf(file, "record.start_recording_hotkey " FORMAT_I64 " " FORMAT_U32 "\n", config.record_config.start_recording_hotkey.keysym, config.record_config.start_recording_hotkey.modifiers); fprintf(file, "replay.save_directory %s\n", config.replay_config.save_directory.c_str()); fprintf(file, "replay.container %s\n", config.replay_config.container.c_str()); fprintf(file, "replay.time %d\n", config.replay_config.replay_time); - fprintf(file, "replay.start_recording_hotkey %ld %u\n", config.replay_config.start_recording_hotkey.keysym, config.replay_config.start_recording_hotkey.modifiers); - fprintf(file, "replay.save_recording_hotkey %ld %u\n", config.replay_config.save_recording_hotkey.keysym, config.replay_config.save_recording_hotkey.modifiers); + fprintf(file, "replay.start_recording_hotkey " FORMAT_I64 " " FORMAT_U32 "\n", config.replay_config.start_recording_hotkey.keysym, config.replay_config.start_recording_hotkey.modifiers); + fprintf(file, "replay.save_recording_hotkey " FORMAT_I64 " " FORMAT_U32 "\n", config.replay_config.save_recording_hotkey.keysym, config.replay_config.save_recording_hotkey.modifiers); fclose(file); } -- cgit v1.2.3