Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

old style type cast warning fixed #73

Merged
merged 5 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion examples/simple/universal/build/_deps/cpp_wrapper-src
Submodule cpp_wrapper-src deleted from d93144
1 change: 0 additions & 1 deletion examples/simple/universal/build/_deps/zenohc_backend-src
Submodule zenohc_backend-src deleted from 590bea
Submodule zenohpico_backend-src deleted from 3e366a
2 changes: 1 addition & 1 deletion include/zenohcxx/impl.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(id.id[i]);
return os;
}

Expand Down
2 changes: 0 additions & 2 deletions include/zenohpico.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
#define __ZENOHCXX_ZENOHPICO
#undef __ZENOHCXX_ZENOHC

typedef bool _Bool;

#include "zenoh-pico.h"
#include "zenohcxx/base.hxx"

Expand Down
21 changes: 21 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
30 changes: 30 additions & 0 deletions tests/build/warnings.cxx
Original file line number Diff line number Diff line change
@@ -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, <[email protected]>
//

// 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; }
Loading