cpp20-http-client
cpp20-http-client copied to clipboard
Fix GCC & Clang build in GitHub Actions
WORKING GitHub Actions CI/CD for now :). MacOS can be done latter, this pull request is already big enough.
- [x] Fix build for both GCC & Clang
- [x] Improve README and how to use cmake with
-B
- [x] Moving some specific GNU compilers behind a guard check
- [x] Moved to latest Clang version (Clang 17 to get it compiled)
- [x] Add sign-conversion warning flag (default in GitHub Actions)
- [x] Add unused variable warning flag (default in GitHub Actions)
- [x] Fixed a lot of compile warning & errors:
- Fixed:
warning: braces around scalar initializer [-Wbraced-scalar-init]
- Brackets around
&&
-
implicit conversion changes signedness: 'std::size_t' (aka 'unsigned long') to 'difference_type'
- This list goes on and on... (see all the failed builds lol)
- Fixed:
- [x] Use unused variable
received_data
variable in socket example, and add an example that prints the bytes to console out.
Some output info:
[build] /media/melroy/Data/Projects/cpp20-http-client/source/cpp20_http_client.cpp:1088:14: warning: braces around scalar initializer [-Wbraced-scalar-init]
[build] 1088 | .ai_family{AF_UNSPEC},
[build] | ^~~~~~~~~~~
[build] |
[build] /media/melroy/Data/Projects/cpp20-http-client/source/cpp20_http_client.cpp:1089:16: warning: braces around scalar initializer [-Wbraced-scalar-init]
[build] 1089 | .ai_socktype{SOCK_STREAM},
[build] | ^~~~~~~~~~~~~
[build] |
[build] /media/melroy/Data/Projects/cpp20-http-client/source/cpp20_http_client.cpp:1090:16: warning: braces around scalar initializer [-Wbraced-scalar-init]
[build] 1090 | .ai_protocol{IPPROTO_TCP},
[build] | ^~~~~~~~~~~~~
[build] |
And more info:
/home/runner/work/cpp20-http-client/cpp20-http-client/include/cpp20_http_client.hpp:356:10: error: implicit conversion changes signedness: 'range_difference_t<const vector<byte, allocator<byte>> &>' (aka 'long') to 'std::size_t' (aka 'unsigned long') [-Werror,-Wsign-conversion]
356 | return std::ranges::distance(data);
| ~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/runner/work/cpp20-http-client/cpp20-http-client/include/cpp20_http_client.hpp:391:28: note: in instantiation of function template specialization 'http_client::utils::size_of_byte_data<std::vector<std::byte>>' requested here
391 | auto buffer = DataVector((size_of_byte_data(arguments) + ...));
| ^
/home/runner/work/cpp20-http-client/cpp20-http-client/include/cpp20_http_client.hpp:1865:36: note: in instantiation of function template specialization 'http_client::utils::concatenate_byte_data<std::basic_string_view<char>, char, std::basic_string_view<char>, std::basic_string_view<char>, std::basic_string_view<char>, std::basic_string<char>, std::basic_string_view<char>, std::vector<std::byte>>' requested here
1865 | auto const request_data = utils::concatenate_byte_data(
| ^
/home/runner/work/cpp20-http-client/cpp20-http-client/include/cpp20_http_client.hpp:356:10: error: implicit conversion changes signedness: 'range_difference_t<const basic_string_view<char, char_traits<char>> &>' (aka 'long') to 'std::size_t' (aka 'unsigned long') [-Werror,-Wsign-conversion]
356 | return std::ranges::distance(data);
| ~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/runner/work/cpp20-http-client/cpp20-http-client/include/cpp20_http_client.hpp:391:28: note: in instantiation of function template specialization 'http_client::utils::size_of_byte_data<std::basic_string_view<char>>' requested here
391 | auto buffer = DataVector((size_of_byte_data(arguments) + ...));
| ^
@avocadoboi The build is working now! Please review and merge.
Great work! What was the reason for adding
target_include_directories(cpp20_http_client_test PRIVATE ${Catch2_INCLUDE_DIRS})
?
Great work! What was the reason for adding
target_include_directories(cpp20_http_client_test PRIVATE ${Catch2_INCLUDE_DIRS})
?
I was trying to get Catch2 working with MacOS actually. But I gave up macos for now ;P You can remove this line for now if you wish.
ps. Also you moved to catch3 hence the reason the build is now failing: https://github.com/avocadoboi/cpp20-http-client/actions/runs/7308971586/job/19916115844
Ah okay, I will remove that for now then. What do you think about using VCPKG in GitHub actions, in order to use the latest version of catch2? This looks promising: https://github.com/marketplace/actions/vcpkg-action
Ah okay, I will remove that for now then. What do you think about using VCPKG in GitHub actions, in order to use the latest version of catch2? This looks promising: https://github.com/marketplace/actions/vcpkg-action
Sure if you want to use that. Ideally you don't need it, because you can just leverage cmake fetch content for your dependencies like catch2 or catch3.
An issue with that is that we can't easily do the same with OpenSSL. I think using VCPKG will allow us to build on MacOS as well! I will try to do this :)
Yea with macos I was using brew