Skip to content

Commit

Permalink
Fix compiler warnings in generated protobuf sources
Browse files Browse the repository at this point in the history
  • Loading branch information
janhenke committed Apr 8, 2024
1 parent acbfac3 commit 4a421e5
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 23 deletions.
2 changes: 1 addition & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
"toolset": "v143",
"cacheVariables": {
"CMAKE_C_FLAGS": "/W4 /utf-8",
"CMAKE_CXX_FLAGS": "/W4 /utf-8"
"CMAKE_CXX_FLAGS": "/W4 /utf-8 /EHsc"
},
"condition": {
"type": "equals",
Expand Down
8 changes: 0 additions & 8 deletions client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@ target_compile_definitions(
PUBLIC ASIO_NO_DEPRECATED
)

# enable extra warnings for our code
target_compile_options(
mumble_client
PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/W4>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Wpedantic>
)

find_package(asio CONFIG REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(spdlog CONFIG REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion client/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <iostream>
#include <thread>

int main(int argc, char *argv[]) {
auto main(int argc, char *argv[]) -> int {
using namespace std::chrono_literals;
using namespace libmumble_protocol::client;

Expand Down
8 changes: 8 additions & 0 deletions common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ protobuf_generate(
)
generate_export_header(mumble_protocol_common)

# Disable specific compiler warnings for generated file (because we cannot fix the warnings)
set_source_files_properties(
${CMAKE_CURRENT_BINARY_DIR}/src/Mumble.pb.cc
${CMAKE_CURRENT_BINARY_DIR}/src/MumbleUDP.pb.cc
PROPERTIES
COMPILE_FLAGS $<IF:$<CXX_COMPILER_ID:MSVC>,/wd4244,-Wno-error=narrowing>
)

set_target_properties(
mumble_protocol_common
PROPERTIES
Expand Down
4 changes: 2 additions & 2 deletions common/src/pimpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class Pimpl {

~Pimpl();

T *operator->();
auto operator->() -> T *;

T &operator*();
auto operator*() -> T &;
};

}// namespace libmumble_protocol::common
Expand Down
4 changes: 2 additions & 2 deletions common/src/pimpl_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ template<typename T>
Pimpl<T>::~Pimpl() = default;

template<typename T>
T *Pimpl<T>::operator->() {
auto Pimpl<T>::operator->() -> T * {
return m.get();
}

template<typename T>
T &Pimpl<T>::operator*() {
auto Pimpl<T>::operator*() -> T & {
return *m.get();
}

Expand Down
8 changes: 0 additions & 8 deletions server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@ target_compile_definitions(
PUBLIC ASIO_NO_DEPRECATED
)

# enable extra warnings for our code
target_compile_options(
mumble_server
PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/W4>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Wpedantic>
)

find_package(asio CONFIG REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(spdlog CONFIG REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion server/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <server.hpp>

int main(int argc, char *argv[]) {
auto main(int argc, char *argv[]) -> int {
(void) argc;
(void) argv;

Expand Down

0 comments on commit 4a421e5

Please sign in to comment.