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

some errors #43

Open
jackeykong opened this issue Oct 9, 2021 · 11 comments
Open

some errors #43

jackeykong opened this issue Oct 9, 2021 · 11 comments

Comments

@jackeykong
Copy link

  1. On Windows, there is no 'ssize_t' type.
  2. 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()); }
@jamesdbrock
Copy link
Owner

Hi, thanks for opening this issue.

  1. 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.

  1. 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?

jamesdbrock added a commit that referenced this issue Oct 10, 2021
Return `size_t` instead of `ssize_t`

Issue #43
@jamesdbrock
Copy link
Owner

I tagged v1.1.1 for the ssize_t bugfix. https://github.com/jamesdbrock/hffix/releases/tag/v1.1.1

@jackeykong
Copy link
Author

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++); }

  1. should be use std::find_if to find out iterator i
  2. iterator i has no begin and size members

@jackeykong
Copy link
Author

Hi, thanks for opening this issue.

  1. 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.

  1. 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?

But, std::string_view::begin and std::string_view::end return std::basic_string_view<CharT,Traits> instead of const char*

@jackeykong jackeykong reopened this Oct 11, 2021
@jamesdbrock
Copy link
Owner

I also found a small error in the Multi-threaded Sending section of the readme.md file.

Thanks!

@jamesdbrock
Copy link
Owner

jamesdbrock commented Oct 11, 2021

But, std::string_view::begin and std::string_view::end return std::basic_string_view<CharT,Traits> instead of const 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

@jackeykong
Copy link
Author

But, std::string_view::begin and std::string_view::end return std::basic_string_view<CharT,Traits> instead of const 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

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 *'

@jamesdbrock
Copy link
Owner

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?

@jackeykong
Copy link
Author

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()); }

@jamesdbrock
Copy link
Owner

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

@enricodetoma
Copy link
Contributor

I created pull request #56 after encountering the same problem with MSVC

jamesdbrock pushed a commit that referenced this issue Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants