foxglove / ws-protocol

Foxglove Studio WebSocket protocol specification and libraries

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

C++20 support

jhurliman opened this issue · comments

Description

../apps/websocket_node/foxglove_websocket/include/foxglove/websocket/websocket_server.hpp:266:37: error: aggregate initialization of type 'foxglove::Server<foxglove::WebSocketNoTls>::ClientInfo' with user-declared constructors is incompatible with C++20 [-Werror,-Wc++20-compat]
    _clients.emplace(hdl, ClientInfo{endpoint, hdl, {}, {}});
                                    ^~~~~~~~~~~~~~~~~~~~~~~

Internal tracking ticket: FG-2707

Is the issue that we are doing something that requires newer C++ or we are doing something that is ok in older C++ but not ok in newer?

We are doing something that is ok in C++17 and earlier but (apparently) not allowed in C++20. The codebase I'm trying to integrate this library into builds as C++20.

There's a simple solution in this case, declare a new constructor:

ClientInfo(const std::string& name, ConnHandle handle)
        : name(name)
        , handle(handle) {}

And instantiate with ClientInfo{endpoint, hdl}

👍 Sounds good. I'm changing this to a feature request for c++20 - seems like we only support c++17 right now. I've thrown this into an upcoming work stream since it looks like an easy fix. We'll also update the README with the c++ version we believe is supported when we update to support c++20 so folks from the future don't get too many ideas.