jcon-cpp icon indicating copy to clipboard operation
jcon-cpp copied to clipboard

error: 'auto' not allowed in lambda parameter

Open Emidizda opened this issue 5 years ago • 4 comments

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<QString>(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

Emidizda avatar Jun 16 '20 18:06 Emidizda

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

joncol avatar Jun 17 '20 06:06 joncol

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

Emidizda avatar Jun 17 '20 08:06 Emidizda

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).

joncol avatar Jun 17 '20 09:06 joncol

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!

Emidizda avatar Jun 17 '20 15:06 Emidizda