I'm making a basic client-server architecture in C++ using Boost::ASIO.
MSVC reports a syntax error: '.'
(C2059) at this line:
void
Server::start()
{
m_stopped = false;
listen_one();
m_runner = std::make_unique<std::thread>([this](){
io_service.run(); // <- syntax error: '.'
});
m_runner->detach();
}
- GCC and Clang both compile the same code on Linux and macOS just fine.
- The code has been changed several times and compiled several imes, and the error persists.
- There is this other block of code, which MSVC does not detect as an error:
void
Client::init()
{
m_socket->connect(boost::asio::ip::tcp::endpoint(
boost::asio::ip::address::from_string(m_ip),
static_cast<short unsigned int>(m_port)));
Connection::init();
m_runner = std::make_unique<std::thread>([this](){
io_service.run(); // <- this line is fine
});
m_runner->detach();
}
Basic debugging:
io_service
,m_stopped
,m_runner
are member variables of Server, andlisten_one()
is a member function.- Server does not inherit anything. (If relevant, Client inherits another class, Connection)
Why does MSVC detect a syntax error, but neither GCC nor Clang do?