小编e.p*_*kov的帖子

如何避免使用 CMake FetchContent 进行更新检查?

全部。

\n

我决定使用新的 cmake 宏来下载外部依赖项。\n我从 Catch2 库的文档中获取了示例代码。

\n
include(FetchContent)\n\nFetchContent_Declare(\n    Catch2\n    GIT_REPOSITORY https://github.com/catchorg/Catch2.git\n    GIT_TAG        v2.13.4\n)\nFetchContent_GetProperties(Catch2)\nif(NOT Catch2_POPULATED)\n    FetchContent_Populate(Catch2)\n    add_subdirectory(${catch2_SOURCE_DIR} ${catch2_BINARY_DIR})\nendif()\n
Run Code Online (Sandbox Code Playgroud)\n

该解决方案效果很好,除了在我离线时重新启动 cmake 的能力(没有 wifi 和移动网络,只有我和我的笔记本电脑)。\n我收到以下错误:

\n
[0/7] Performing update step for 'catch2-populate'\nfatal: \xc2\xabhttps://github.com/catchorg/Catch2.git/\xc2\xbb \xd0\xbd\xd0\xb5\xd0\xb4\xd0\xbe\xd1\x81\xd1\x82\xd1\x83\xd0\xbf\xd0\xbd\xd0\xbe: Could not resolve host: github.com\nCMake Error at /Users/evgeny.proydakov/repository/ihft/build/_deps/catch2-subbuild/catch2-populate-prefix/tmp/catch2-populate-gitupdate.cmake:97 (execute_process):\n  execute_process failed command indexes:\n\n    1: "Child return code: 128"\n\nFAILED: catch2-populate-prefix/src/catch2-populate-stamp/catch2-populate-update \ncd /Users/evgeny.proydakov/repository/ihft/build/_deps/catch2-src && /usr/local/Cellar/cmake/3.20.1/bin/cmake -P /Users/evgeny.proydakov/repository/ihft/build/_deps/catch2-subbuild/catch2-populate-prefix/tmp/catch2-populate-gitupdate.cmake\nninja: build stopped: subcommand failed.\n\nCMake Error at /usr/local/Cellar/cmake/3.20.1/share/cmake/Modules/FetchContent.cmake:1012 (message):\n  Build step for catch2 failed: 1\nCall Stack (most recent call first):\n  /usr/local/Cellar/cmake/3.20.1/share/cmake/Modules/FetchContent.cmake:1141:EVAL:2 (__FetchContent_directPopulate)\n  /usr/local/Cellar/cmake/3.20.1/share/cmake/Modules/FetchContent.cmake:1141 …
Run Code Online (Sandbox Code Playgroud)

c++ cmake catch2

10
推荐指数
1
解决办法
3886
查看次数

在同一台 Linux 机器上从不同接口发送和接收多播

我有一个包含多台计算机的网络,每台计算机都有多个网络接口和一个目标。我正在开发一个积极使用多播的应用程序。总的来说,一切都按预期进行。除了我无法在通过第二个网络接口发送的同一台计算机上接收多播的那一刻之外。网络上的其他计算机可以通过任何网络接口接收多播。是否可以通过一个接口发送多播并通过同一网络中的另一个接口接收多播?如果是这样,我在哪里犯了错误:在客户端代码中,在收件人代码中,还是在系统设置中?

典型机器配置:

$ ifconfig 
enp0s31f6: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
    inet 192.168.88.230  netmask 255.255.255.0  broadcast 192.168.88.255

enp10s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
    inet 192.168.88.229  netmask 255.255.255.0  broadcast 192.168.88.255

wlp6s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
    inet 192.168.88.48  netmask 255.255.255.0  broadcast 192.168.88.255

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
    inet 127.0.0.1  netmask 255.0.0.0
Run Code Online (Sandbox Code Playgroud)

路由表:

$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.88.1    0.0.0.0         UG    100    0        0 enp0s31f6
0.0.0.0         192.168.88.1    0.0.0.0         UG    101    0        0 enp10s0
0.0.0.0         192.168.88.1    0.0.0.0         UG    600 …
Run Code Online (Sandbox Code Playgroud)

c sockets linux udp multicast

8
推荐指数
1
解决办法
2770
查看次数

如何复制或重用boost :: asio :: streambuf?

我正在使用boost asio实现一些带有一些业务逻辑的http代理服务器.

在点(1)boost :: asio :: streambuf response_包含http标头和http主体的一部分.

解析后使用http_response :: parse buffer boost :: asio :: streambuf response_为空.

在(2)我检查所有业务逻辑和读取正文,如果标题中有Content-Length标题.

然后,如果response_ data符合特定条件,我想将原始response_ buffer 发送到另一个套接字(3).

问题是解析后缓冲区是空的.有没有办法复制boost :: asio :: streambuf来重用数据?

void http_response::parse(boost::asio::streambuf& buffer)
{
    std::istream response_stream(&buffer);
    response_stream >> version_;
    response_stream >> status_code_;
    response_stream >> status_message_;
    std::string key;
    std::string value;
    std::string header;
    std::getline(response_stream, header);
    while (std::getline(response_stream, header) && header != "\r") {
        header.resize(header.size() - 1);
        std::size_t found = header.find(':');
        if (found != std::string::npos) …
Run Code Online (Sandbox Code Playgroud)

c++ boost boost-asio

4
推荐指数
1
解决办法
3329
查看次数

模板特化GCC中的语法错误,但不是MSVC

下面的代码使用MSVC 2008编译得很好.当你构建GCC时会遇到很多错误(代码后出错).应该怎么做才能解决错误?

#define FORCE_INLINE inline
#define CREF(A) const A&

template <class F>
class RDOFunCalcStd: public RDOFunCalc
{
    ...

    template <int paramCount>
    FORCE_INLINE void calc(CREF(LPRDORuntime) pRuntime);

    template <>
    FORCE_INLINE void calc<1>(CREF(LPRDORuntime) pRuntime)
    {
        m_value = m_pFunction(getParam<F::arg1_type>(pRuntime, 0));
    }

    template <>
    FORCE_INLINE void calc<2>(CREF(LPRDORuntime) pRuntime)
    {
        m_value = m_pFunction(getParam<F::arg1_type>(pRuntime, 0), getParam<F::arg2_type>(pRuntime, 1));
    }
};
Run Code Online (Sandbox Code Playgroud)

GCC提供以下错误:

error: too many template-parameter-lists

error: explicit specialization in non-namespace scope ‘class rdoRuntime::RDOFunCalcStd<F>’

error: variable or field ‘calc’ declared void

error: expected ‘;’ before ‘<’ token

error: expected …
Run Code Online (Sandbox Code Playgroud)

c++ syntax gcc templates visual-c++

1
推荐指数
1
解决办法
1303
查看次数

标签 统计

c++ ×3

boost ×1

boost-asio ×1

c ×1

catch2 ×1

cmake ×1

gcc ×1

linux ×1

multicast ×1

sockets ×1

syntax ×1

templates ×1

udp ×1

visual-c++ ×1