Skip to content

Commit

Permalink
fix Windows Build (#10)
Browse files Browse the repository at this point in the history
- Fix portability of vector iterator
- Fix casting to HANDLE
  • Loading branch information
HTRamsey authored Aug 19, 2024
1 parent 4d468f9 commit 70c8256
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ulog_cpp/messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ Value::NativeTypeVariant Value::asNativeTypeVariant() const
if (_backing_ref_end - string_start_iterator < _field_ref.arrayLength()) {
throw AccessException("Decoding fault, memory too short");
}
int string_length = strnlen(string_start_iterator.base(), _field_ref.arrayLength());
const int string_length = strnlen(&(*string_start_iterator), _field_ref.arrayLength());
return std::string(string_start_iterator, string_start_iterator + string_length);
}

Expand Down
7 changes: 4 additions & 3 deletions ulog_cpp/simple_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

#include "simple_writer.hpp"

#ifdef WINDOWS
#ifdef _WIN32
#include <windows.h> // NOLINT
#include <fileapi.h>
#else
#include <unistd.h>
Expand Down Expand Up @@ -112,8 +113,8 @@ void SimpleWriter::fsync()
{
if (_file) {
fflush(_file);
#ifdef WINDOWS
FlushFileBuffers(static_cast<HANDLE>(_fileno(_file)));
#ifdef _WIN32
FlushFileBuffers(reinterpret_cast<HANDLE>(static_cast<uintptr_t>(_fileno(_file))));
#else
::fsync(fileno(_file));
#endif
Expand Down

0 comments on commit 70c8256

Please sign in to comment.