Different qtcreator behavior in compiling code
-
I'm trying to compile this code using Qtcreator:
uWS::App().ws<PerSocketData>("/*", { /* Settings */ .compression = uWS::DEDICATED_COMPRESSOR_3KB, .maxPayloadLength = 16 * 1024 * 1024, .idleTimeout = 10, .maxBackpressure = 1 * 1024 * 1024, /* Handlers */ .upgrade = nullptr, .open = [](auto *ws) { /* Let's make every connection subscribe to the "broadcast" topic */ ws->subscribe("broadcast"); }, .message = [](auto *ws, std::string_view message, uWS::OpCode opCode) { /* Exit gracefully if we get a closedown message (ASAN debug) */ if (message == "closedown") { /* Bye bye */ us_listen_socket_close(0, global_listen_socket); ws->close(); } /* Simply broadcast every single message we get */ ws->publish("broadcast", message, opCode, true); }, .drain = [](auto */*ws*/) { /* Check getBufferedAmount here */ }, .ping = [](auto */*ws*/, std::string_view) { }, .pong = [](auto */*ws*/, std::string_view) { }, .close = [](auto */*ws*/, int /*code*/, std::string_view /*message*/) { /* We automatically unsubscribe from any topic here */ } }).listen(9001, [](auto *listen_socket) { global_listen_socket = listen_socket; if (listen_socket) { std::cout << "Listening on port " << 9001 << std::endl; } }).run();
and get this error:
cannot convert '<brace-enclosed initializer list>' to 'uWS::TemplatedApp<false>::WebSocketBehaviormanagement::Websocket::Runner()::PerSocketData.But I compile same code using same compiler (arm-poky-linux-gnueabi-g++) in command line successfully.
What is wrong?
Anyway I change my code to this and it compiled fine in Qtcreator too.uWS::TemplatedApp<false>::WebSocketBehavior<PerSocketData> wsb = { /* Settings */ .compression = uWS::SHARED_COMPRESSOR, .maxPayloadLength = 16 * 1024, .idleTimeout = 10, .maxBackpressure = 1 * 1024 * 1024, /* Handlers */ .upgrade = nullptr, .open = [=](auto* ws) { //std::cout << "connected" << std::endl; is_there_stream = true; //g_ws = ws; }, .message = [](auto* ws, std::string_view message, uWS::OpCode opCode) { //ws->send(message, opCode, true); std::cout << message << std::endl; }, .drain = [](auto*/*ws*/) { /* Check ws->getBufferedAmount() here */ }, // .ping = [](auto*/*ws*/) { // /* Not implemented yet */ // }, // .pong = [](auto*/*ws*/) { // /* Not implemented yet */ // }, .close = [=](auto*/*ws*/, int /*code*/, std::string_view /*message*/) { /* You may access ws->getUserData() here */ is_there_stream = false; } }; uWS::App().ws<PerSocketData>("/*", std::move(wsb)).get("/restart", [](auto* res, auto* req) { //protocol->Restart(); }).listen(PORT, [](auto* listen_socket) { if (listen_socket) { std::cout << "Listening on port " << PORT << std::endl; } }).run();
There is no problem in compiling right now but I don't know what happened.
Why the same compiler shows these different behaviors?PS: full code is here
-Majid
-
@majid said in Different qtcreator behavior in compiling code:
Why the same compiler shows these different behaviors?
Are you sure you use same compiler in QtCreator? Did you select the correct Kit in QtCreator?
-
@jsulm said in Different qtcreator behavior in compiling code:
Are you sure you use same compiler in QtCreator? Did you select the correct Kit in QtCreator?
Yes, I'm sure.
this is a part of Qtcreator compile output:arm-poky-linux-gnueabi-g++ -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=/opt/fsl-imx-fb/5.4-zeus/sysroots/cortexa7t2hf-neon-poky-linux-gnueabi -c -pipe -O2 -pipe -g -feliminate-unused-debug-types --sysroot=/opt/fsl-imx-fb/5.4-zeus/sysroots/cortexa7t2hf-neon-poky-linux-gnueabi -g -std=gnu++1z ................
and this part of make output:
arm-poky-linux-gnueabi-g++ -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=/opt/fsl-imx-fb/5.4-zeus/sysroots/cortexa7t2hf-neon-poky-linux-gnueabi -flto -O3 -O2 -pipe -g -feliminate-unused-debug-types -lpthread -Wpedantic -Wall -Wextra -Wsign-conversion -Wconversion -std=c++2a ...........
The compiler is same but options are different. I tried also compile come with same std option (that I think it is important one) but nothing changed.
-
@majid said in Different qtcreator behavior in compiling code:
like I said,
-std=gnu++1z
vs-std=c++2a
probably the cause