joncol / jcon-cpp

JSON RPC 2.0 library using C++ and Qt 6
MIT License
190 stars 65 forks source link

error: 'auto' not allowed in lambda parameter #53

Open peder2key opened 4 years ago

peder2key commented 4 years ago

Hello!

I am getting this error in json_rpc_server.cpp: error: 'auto' not allowed in lambda parameter

in method: QString logInvoke(const QMetaMethod& meta_method, const QVariantList& args, const QVariant& return_value) { const auto ns = meta_method.parameterNames(); auto ps = jcon::variantListToStringList(args); QStringList args_sl; std::transform(ns.begin(), ns.end(), ps.begin(), std::back_inserter(args_sl), [](auto x, auto y) -> QString { return static_cast(x) + ": " + y; } );

auto msg = QString("%1 invoked ")
    .arg(static_cast<QString>(meta_method.name()));

if (args_sl.empty()) {
    msg += "without arguments";
} else {
    msg += QString("with argument%1: %2")
        .arg(args_sl.size() == 1 ? "" : "s")
        .arg(args_sl.join(", "));
}

if (return_value.isValid()) {
    msg += " -> returning: " + jcon::variantToString(return_value);
}

return msg;

}

not sure why?

best regards

joncol commented 4 years ago

Hi, could you try reformatting that code so that it's easier to follow what you're asking?

peder2key commented 4 years ago

I just downloaded the code and tried to compile it with Qt5.15.0.. But this dont seem to be the problem for windows, but I am getting this error:

error: definition of static data member 'jcon::JsonRpcServer::InvalidRequestId' of dllimport'd class const QString JsonRpcServer::InvalidRequestId = "";

Have you tested it with Qt5.15.0?

Best regards

joncol commented 4 years ago

Just tried Qt 5.15, and had to suppress a deprecation warning (pushed the change to master), but other than that it should work fine (I'm on Arch Linux though, I haven't tried it on Windows).

peder2key commented 4 years ago

Thanks!

I was able to compile it on my mac, but when i tested the example code this was the result:

Creating TCP server RPC error: "method 'getRandomInt' not found, check name and parameter types " ( -32601 ) RPC error: "method 'getRandomInt' not found, check name and parameter types (-32601)" RPC error: "method 'printMessage' not found, check name and parameter types (-32601)" Waiting for 2 outstanding requests Calling QCoreApplication::processEvents() RPC error: "method 'printMessage' not found, check name and parameter types " ( -32601 ) Calling QCoreApplication::processEvents() RPC error: "method 'namedParams' not found, check name and parameter types " ( -32601 ) Creating TCP server RPC error: "method 'ex/myFirstNamespace/getRandomInt' not found, check name and parameter types (-32601)" RPC error: "method 'ex/myOtherNamespace/getRandomInt' not found, check name and parameter types (-32601)" No outstanding requests, quitting

Any tips for why it is failing?

Best regards!