diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index f081cd77..788e3a91 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -30,17 +30,6 @@ function(add_example file mode lib) target_link_libraries(${target} PUBLIC ${lib}) set_property(TARGET ${target} PROPERTY LANGUAGE CXX) set_property(TARGET ${target} PROPERTY CXX_STANDARD 17) - - # Enable all warnings and treat warnings as errors only when building examples. - # Supposedly, enabling it for examples only, but not for the library target itself - # is a good compromise. It guarantees the continuous checking the code and do not - # breaks dependent projects if warnings are mistakenly introduced in the library. - if(MSVC) - target_compile_options(${target} PRIVATE /W4 /WX) - else() - target_compile_options(${target} PRIVATE -Wall -Wextra -Wpedantic -Werror) - endif() - endfunction() function(add_examples glob mode lib) diff --git a/examples/simple/universal/build/_deps/cpp_wrapper-src b/examples/simple/universal/build/_deps/cpp_wrapper-src deleted file mode 160000 index d93144d4..00000000 --- a/examples/simple/universal/build/_deps/cpp_wrapper-src +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d93144d49ad2b700c86c1f8fb640581576f56c73 diff --git a/examples/simple/universal/build/_deps/zenohc_backend-src b/examples/simple/universal/build/_deps/zenohc_backend-src deleted file mode 160000 index 590bea93..00000000 --- a/examples/simple/universal/build/_deps/zenohc_backend-src +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 590bea934f7642261405ae8cbfa8bf4834d0bfe5 diff --git a/examples/simple/universal/build/_deps/zenohpico_backend-src b/examples/simple/universal/build/_deps/zenohpico_backend-src deleted file mode 160000 index 3e366a57..00000000 --- a/examples/simple/universal/build/_deps/zenohpico_backend-src +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3e366a575e472e4f28b5a97007b2a5c1ed9e17b9 diff --git a/include/zenohcxx/impl.hxx b/include/zenohcxx/impl.hxx index 46a8fad8..243099cc 100644 --- a/include/zenohcxx/impl.hxx +++ b/include/zenohcxx/impl.hxx @@ -39,7 +39,7 @@ inline ::z_bytes_t z::BytesView::init(const uint8_t* start, size_t len) { inline std::ostream& operator<<(std::ostream& os, const z::Id& id) { for (size_t i = 0; id.id[i] != 0 && i < 16; i++) - os << std::hex << std::setfill('0') << std::setw(2) << (int)id.id[i]; + os << std::hex << std::setfill('0') << std::setw(2) << static_cast(id.id[i]); return os; } diff --git a/include/zenohpico.hxx b/include/zenohpico.hxx index e7f69888..15817258 100644 --- a/include/zenohpico.hxx +++ b/include/zenohpico.hxx @@ -16,8 +16,6 @@ #define __ZENOHCXX_ZENOHPICO #undef __ZENOHCXX_ZENOHC -typedef bool _Bool; - #include "zenoh-pico.h" #include "zenohcxx/base.hxx" diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6dc58d08..a829e4a0 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -34,3 +34,24 @@ foreach(file ${files}) add_test_instance(${file} zenohpico zenohcxx::zenohpico) endforeach() +function(set_strict_warnings file mode) + get_filename_component(filename ${file} NAME_WE) + set(target ${filename}_${mode}) + # Enable all warnings and treat warnings as errors + # to check that library can be built in maximally strict mode + if(MSVC) + target_compile_options(${target} PRIVATE /W4 /WX) + else() + target_compile_options(${target} PRIVATE + -Wall + -Wextra + -Wpedantic + -Wold-style-cast + -Werror) + endif() +endfunction() + +add_test_instance(${CMAKE_CURRENT_SOURCE_DIR}/build/warnings.cxx zenohc zenohcxx::zenohc::static) +add_test_instance(${CMAKE_CURRENT_SOURCE_DIR}/build/warnings.cxx zenohpico zenohcxx::zenohpico) +set_strict_warnings(${CMAKE_CURRENT_SOURCE_DIR}/build/warnings.hxx zenohc) +set_strict_warnings(${CMAKE_CURRENT_SOURCE_DIR}/build/warnings.hxx zenohpico) diff --git a/tests/build/warnings.cxx b/tests/build/warnings.cxx new file mode 100644 index 00000000..0697130a --- /dev/null +++ b/tests/build/warnings.cxx @@ -0,0 +1,30 @@ +// +// Copyright (c) 2023 ZettaScale Technology +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +// which is available at https://www.apache.org/licenses/LICENSE-2.0. +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// +// Contributors: +// ZettaScale Zenoh Team, +// + +// Disable 'old-style-cast` warning for C headers only +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wold-style-cast" +#ifdef ZENOHCXX_ZENOHPICO +#include "zenoh-pico.h" +#endif +#ifdef ZENOHCXX_ZENOHC +#include "zenoh.h" +#endif +#pragma GCC diagnostic pop + +#include "zenoh.hxx" + +using namespace zenoh; + +int main() { return 0; } \ No newline at end of file