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

use it as a package and fix some compilation errors #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ else()
endif()

target_sources(bitpacker INTERFACE
include/bitpacker/bitpacker.hpp
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/bitpacker/bitpacker.hpp>
)

target_include_directories(bitpacker INTERFACE
Expand All @@ -30,12 +30,12 @@ target_include_directories(bitpacker INTERFACE

## packaging and testing: probably only want if this is not a sub-project
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
option(ENABLE_TESTING "Enable Test Builds" ON)
option(ENABLE_TESTING "Enable Test Builds" OFF)
if(ENABLE_TESTING)
enable_testing()
message("Building Tests...")
add_subdirectory(tests)
endif()

#add_subdirectory(packaging)
add_subdirectory(packaging)
endif()
6 changes: 6 additions & 0 deletions cmake/bitpackerConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
check_required_components(
"@PROJECT_NAME@"
)
8 changes: 4 additions & 4 deletions include/bitpacker/bitpacker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,14 +673,14 @@ namespace bitpacker {
}

for(int bits = PackedType::bits, idx = 0; bits > 0; bits -= charsize) {
const auto field_size = bits < charsize ? bits : charsize;
const auto field_size = static_cast<unsigned int>(bits) < charsize ? bits : charsize;
insert<uint8_t>(buffer, offset + (idx * charsize), charsize, arr[idx]);
++idx;
}
}
else {
for(int bits = PackedType::bits, idx = 0; bits > 0; bits -= charsize) {
const auto field_size = bits < charsize ? bits : charsize;
const auto field_size = static_cast<unsigned int>(bits) < charsize ? bits : charsize;
insert<uint8_t>(buffer, offset + (idx * charsize), charsize, elem[idx]);
++idx;
}
Expand All @@ -691,9 +691,9 @@ namespace bitpacker {

/// Helper function to insert padding fields into the buffer for `pack_into()`
template <typename Fmt, size_type... Items>
constexpr auto insert_padding(span<byte_type> buffer, const size_type start_bit, std::index_sequence<Items...> /*unused*/)
constexpr auto insert_padding([[maybe_unused]] span<byte_type> buffer, [[maybe_unused]] const size_type start_bit, std::index_sequence<Items...> /*unused*/)
{
constexpr auto formats_only_pad = impl::remove_non_padding(impl::get_type_array(Fmt{}));
[[maybe_unused]] constexpr auto formats_only_pad = impl::remove_non_padding(impl::get_type_array(Fmt{}));
using FormatTypes = std::tuple< typename impl::FormatType< formats_only_pad[Items].formatChar,
formats_only_pad[Items].count,
formats_only_pad[Items].endian >... >;
Expand Down