Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Different qtcreator behavior in compiling code
Forum Updated to NodeBB v4.3 + New Features

Different qtcreator behavior in compiling code

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
6 Posts 3 Posters 510 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    majid
    wrote on last edited by
    #1

    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

    jsulmJ J.HilkJ 2 Replies Last reply
    0
    • M majid

      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

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @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?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      M 1 Reply Last reply
      0
      • M majid

        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

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #3

        @majid are you sure, you're using the same standard as well ? -std:c++latest for example is not supported in all QtC Version which than falls back to the default version


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        M 1 Reply Last reply
        0
        • jsulmJ jsulm

          @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?

          M Offline
          M Offline
          majid
          wrote on last edited by
          #4

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

          J.HilkJ 1 Reply Last reply
          0
          • M majid

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

            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on last edited by
            #5

            @majid said in Different qtcreator behavior in compiling code:

            like I said,

            -std=gnu++1z vs -std=c++2a

            probably the cause


            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            1 Reply Last reply
            0
            • J.HilkJ J.Hilk

              @majid are you sure, you're using the same standard as well ? -std:c++latest for example is not supported in all QtC Version which than falls back to the default version

              M Offline
              M Offline
              majid
              wrote on last edited by
              #6

              @J-Hilk
              I changed -std option value to c++2a same as done in make but nothing changed.

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved