hffix
hffix copied to clipboard
some errors
- On Windows, there is no 'ssize_t' type.
- the 'std::string_view' has no begin and end members.
void push_back_string(int tag, std::string_view s) { push_back_string(tag, s.begin(), s.end()); }
Hi, thanks for opening this issue.
- On Windows, there is no 'ssize_t' type.
You're right, ssize_t
is not standard and we shouldn't use it. I'll fix that.
- the 'std::string_view' has no begin and end members.
void push_back_string(int tag, std::string_view s) { push_back_string(tag, s.begin(), s.end()); }
std::string_view
begin
and end
are standard, starting in C++17. https://en.cppreference.com/w/cpp/string/basic_string_view Do you have a suggestion for what to do about that?
I tagged v1.1.1 for the ssize_t
bugfix. https://github.com/jamesdbrock/hffix/releases/tag/v1.1.1
I also found a small error in the Multi-threaded Sending section of the readme.md file.
hffix::message_reader::const_iterator i = std::find(r.begin(), r.end(), hffix::tag_equal(hffix::tag::MsgSeqNum)); if (i != r.end()) { std::snprintf(const_cast<char*>(i->begin()), i->size(), "%.8i", next_sequence_number++); }
- should be use
std::find_if
to find out iterator i - iterator i has no begin and size members
Hi, thanks for opening this issue.
- On Windows, there is no 'ssize_t' type.
You're right,
ssize_t
is not standard and we shouldn't use it. I'll fix that.
- the 'std::string_view' has no begin and end members.
void push_back_string(int tag, std::string_view s) { push_back_string(tag, s.begin(), s.end()); }
std::string_view
begin
andend
are standard, starting in C++17. https://en.cppreference.com/w/cpp/string/basic_string_view Do you have a suggestion for what to do about that?
But, std::string_view::begin
and std::string_view::end
return std::basic_string_view<CharT,Traits>
instead of const char*
I also found a small error in the Multi-threaded Sending section of the readme.md file.
Thanks!
But,
std::string_view::begin
andstd::string_view::end
returnstd::basic_string_view<CharT,Traits>
instead ofconst char*
They return a std::basic_string_view<char>::const_iterator
which will be type const char *
. Or is it not type const char *
in your Windows environment? I guess if it's not const char *
then push_back_string(int tag, std::string_view s)
will fail to typecheck, is that what's happening for you?
https://en.cppreference.com/w/cpp/string/basic_string_view
https://docs.microsoft.com/en-us/cpp/standard-library/string-view-typedefs?view=msvc-160#string_view
But,
std::string_view::begin
andstd::string_view::end
returnstd::basic_string_view<CharT,Traits>
instead ofconst char*
They return a
std::basic_string_view<char>::const_iterator
which will be typeconst char *
. Or is it not typeconst char *
in your Windows environment? I guess if it's notconst char *
thenpush_back_string(int tag, std::string_view s)
will fail to typecheck, is that what's happening for you?https://en.cppreference.com/w/cpp/string/basic_string_view
https://docs.microsoft.com/en-us/cpp/standard-library/string-view-typedefs?view=msvc-160#string_view
Yes, i use visual studio 2017 on windows, the error message is error C2664: 'void hffix::message_writer::push_back_string(int,std::string_view)': cannot convert argument 2 from 'std::_String_view_iterator<_Traits>' to 'const char *'
I don't have easy access to a Windows machine so it's inconvenient for me to write a fix for this because I can't test it on Windows. Would you like to make a PR to fix this problem?
Yes, I will be happy to do PR. just modify as follows :
void push_back_string(int tag, std::string_view s) { push_back_string(tag, s.data(), s.data() + s.length()); }
Yes, I will be happy to do PR.
Yes please, that looks good. https://en.cppreference.com/w/cpp/string/basic_string_view/data
Do you know how to open a Pull Request? https://github.com/jamesdbrock/hffix/pulls
I created pull request #56 after encountering the same problem with MSVC