Skip to content

Commit

Permalink
fix(network): compile error for std function
Browse files Browse the repository at this point in the history
  • Loading branch information
Cnily03 committed Jul 3, 2024
1 parent 68490b5 commit 12fe749
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 9 deletions.
41 changes: 38 additions & 3 deletions .github/workflows/compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,40 @@ on: [push, pull_request]

jobs:
test:
name: Compile
name: Compile (${{ matrix.sys }})
runs-on: windows-latest
strategy:
matrix:
include:
- { sys: mingw64, env: x86_64 }
- { sys: mingw32, env: i686 }
- { sys: ucrt64, env: ucrt-x86_64 }
- { sys: clang64, env: clang-x86_64 }
defaults:
run:
shell: msys2 {0}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: msys2/setup-msys2@v2
with:
update: true
msystem: mingw64
install: mingw-w64-x86_64-llvm
cache: true
msystem: ${{ matrix.sys }}
install: >-
mingw-w64-${{ matrix.env }}-toolchain
mingw-w64-${{ matrix.env }}-clang
mingw-w64-${{ matrix.env }}-make
make
- name: Add environment variables
run: |
echo "export PATH=/${{ matrix.sys }}/bin:$PATH" >> $GITHUB_ENV
echo "export CC=clang" >> $GITHUB_ENV
echo "export CXX=clang++" >> $GITHUB_ENV
- name: Compile source code
run: |
echo "::group::Clang++ version"
Expand All @@ -21,3 +46,13 @@ jobs:
echo "::group::Compiling"
make
echo "::endgroup::"
- name: Export artifacts
uses: actions/upload-artifact@v2
with:
name: build-artifacts-${{ matrix.env }}
path: |
./transf_server.exe
./transf_client.exe
if-no-files-found: warn
retention-days: 30
9 changes: 5 additions & 4 deletions include/network.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <string>
#include <thread>
#include <vector>
#include <functional>

typedef uint8_t ip_version;
typedef int ip_family;
Expand Down Expand Up @@ -176,7 +177,7 @@ class BasicSocket {
class SocketPeer : public BasicSocket {
protected:
BasicSocket* m_p_bsock_from;
mutable std::list<const PeerCloseHandler> m_pCloseHandlers;
mutable std::list<PeerCloseHandler> m_pCloseHandlers;

public:
SocketPeer() = default;
Expand Down Expand Up @@ -241,9 +242,9 @@ class SocketClient : public BasicSocket {
class SocketServer : public BasicSocket {
protected:
std::map<u_long, SocketPeer&> m_clients; // TODO: unused
mutable std::list<const StreamHandler> m_pStreamHandlers;
mutable std::list<const MessageHandler> m_pMessageHandlers;
mutable std::list<const ServerCloseHandler> m_pCloseHandlers;
mutable std::list<StreamHandler> m_pStreamHandlers;
mutable std::list<MessageHandler> m_pMessageHandlers;
mutable std::list<ServerCloseHandler> m_pCloseHandlers;
int m_max_clients = SOMAXCONN;
mutable bool m_serving = false;
mutable std::vector<std::thread> m_threads;
Expand Down
1 change: 1 addition & 0 deletions src/ansi.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
//===----------------------------------------------------------------------===//
*/

#include <algorithm>
#include <ostream>
#include <sstream>

Expand Down
4 changes: 2 additions & 2 deletions transf_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ int send_file(SocketClient& remote, const std::string& fp, char* buf, int buf_si
rate, "%)", ansi::reset);
}

auto print_fail = [&fp, &ANSI_PREV_LINE, &IS_DEBUG]() {
auto print_fail = [&fp, &IS_DEBUG]() {
logger.print(IS_DEBUG ? ""
: ansi::clear_line + ansi::cursor_prev_line(1) +
ansi::cursor_pos_x(fp.size() + 6),
ansi::rgb_fg(139, 0, 0), " (Failed)", ansi::reset);
};
auto print_success = [&fp, &ANSI_PREV_LINE, &IS_DEBUG]() {
auto print_success = [&fp, &IS_DEBUG]() {
logger.print(IS_DEBUG
? ""
: ansi::clear_line + ansi::cursor_prev_line(1) + ansi::clear_line +
Expand Down

0 comments on commit 12fe749

Please sign in to comment.