Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Why no std::byte in qt?!!
Forum Updated to NodeBB v4.3 + New Features

Why no std::byte in qt?!!

Scheduled Pinned Locked Moved Solved General and Desktop
31 Posts 8 Posters 9.9k Views 3 Watching
  • 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.
  • EngelardE Engelard

    @VRonin like @kenchan said, add in to .pro file one of these:

    CONFIG += c++17
    QMAKE_CXXFLAGS += -std:c++17
    

    Non of them worked. Still no byte type in std::

    K Offline
    K Offline
    kenchan
    wrote on last edited by kenchan
    #22

    @Engelard
    OK, problem solved...
    In spite the Microsoft docs which say the -std:c++17 flag can be used in VS2017 to enable the c++17 features it does not seem to work though the command line via qmake!
    but adding...
    DEFINES += _HAS_STD_BYTE
    and
    QMAKE_CXXFLAGS += -std:c++17
    to the pro file does work and I can use std::byte in the code.

    QMAKE_CXXFLAGS += -std:c++1z also worked

    I hope this works for you too.

    EngelardE 1 Reply Last reply
    4
    • VRoninV VRonin

      @Engelard said in Why no std::byte in qt?!!:

      still it says that byte is not part of std.

      • Did you #include <cstddef>?
      • Can you open Visual Studio 2017, create a simple console program and test if it works there?
      EngelardE Offline
      EngelardE Offline
      Engelard
      wrote on last edited by Engelard
      #23

      @VRonin said in Why no std::byte in qt?!!:

      @Engelard said in Why no std::byte in qt?!!:

      still it says that byte is not part of std.

      • Did you #include <cstddef>?

      Yes, i mentioned in firsts posts.

      • Can you open Visual Studio 2017, create a simple console program and test if it works there?

      In first post i told that original program which widely using std::byte was from my VS2017(ofc it works).

      @kshegunov

      This is the CPU instruction set. Intel processors use amd64, so it's correct.

      lol

      1 Reply Last reply
      0
      • kshegunovK kshegunov

        @Engelard said in Why no std::byte in qt?!!:

        there is compilers for amd chosen, when i have normal for intel i suppose in my VS

        This is the CPU instruction set. Intel processors use amd64, so it's correct.

        EngelardE Offline
        EngelardE Offline
        Engelard
        wrote on last edited by
        #24

        @kshegunov said in Why no std::byte in qt?!!:

        @Engelard said in Why no std::byte in qt?!!:

        there is compilers for amd chosen, when i have normal for intel i suppose in my VS

        This is the CPU instruction set. Intel processors use amd64, so it's correct.

        lol

        @kkoehne said in Why no std::byte in qt?!!:

        @Engelard said in Why no std::byte in qt?!!:

        CONFIG += c++17
        QMAKE_CXXFLAGS += -std:c++17

        Please try

        CONFIG +=c++1z

        This works for me with Visual Studio 2017 compiler.

        Sorry, no effect. Tried both of them, separately and together like in your message.

        1 Reply Last reply
        0
        • K kenchan

          @Engelard
          OK, problem solved...
          In spite the Microsoft docs which say the -std:c++17 flag can be used in VS2017 to enable the c++17 features it does not seem to work though the command line via qmake!
          but adding...
          DEFINES += _HAS_STD_BYTE
          and
          QMAKE_CXXFLAGS += -std:c++17
          to the pro file does work and I can use std::byte in the code.

          QMAKE_CXXFLAGS += -std:c++1z also worked

          I hope this works for you too.

          EngelardE Offline
          EngelardE Offline
          Engelard
          wrote on last edited by Engelard
          #25

          @kenchan damn it worked! At least now after typing std::b it advice me byte type and word now not dead black but violet like all valid variables should be(finally).

          But!)

          It still rejects to compile. I tried to clean all, then rebuild, but same error:

          alt text

          1 Reply Last reply
          0
          • EngelardE Offline
            EngelardE Offline
            Engelard
            wrote on last edited by
            #26

            Even restart of Qt don't help, what's wrong...

            K 1 Reply Last reply
            0
            • EngelardE Engelard

              Even restart of Qt don't help, what's wrong...

              K Offline
              K Offline
              kenchan
              wrote on last edited by kenchan
              #27

              @Engelard
              hmm?? looks like you have another problem somewhere.
              Can you show us your pro file?
              Can you show us a screen shot of your kits panel for the kit you are currently using again please?
              Can you show us a screen shot the qt versions panel and the compilers panel again please?
              Can can you show a screen shot of the compiler output when you compile your code with the std::byte declaration please?

              Thank you

              K EngelardE 2 Replies Last reply
              1
              • K kenchan

                @Engelard
                hmm?? looks like you have another problem somewhere.
                Can you show us your pro file?
                Can you show us a screen shot of your kits panel for the kit you are currently using again please?
                Can you show us a screen shot the qt versions panel and the compilers panel again please?
                Can can you show a screen shot of the compiler output when you compile your code with the std::byte declaration please?

                Thank you

                K Offline
                K Offline
                kenchan
                wrote on last edited by
                #28

                @Engelard
                I few tests show me that you can actually get away with using either DEFINES += _HAS_STD_BYTE or QMAKE_CXXFLAGS += -std:c++17 when using the VS 15.0 compiler.
                Using both is obviously twice as safe.

                Just make sure you blow away the build folder, rerun qmake and rebuild just to be sure.

                creating a new Non-Qt Plain C++ project with this pro file

                 TEMPLATE = app
                CONFIG += console
                CONFIG -= app_bundle
                CONFIG -= qt
                DEFINES += _HAS_STD_BYTE
                QMAKE_CXXFLAGS += -std:c++17
                 
                SOURCES += \
                        main.cpp
                

                and this c++ code worked fine for me.

                #include <iostream>
                #include <cstddef>
                 
                using namespace std;
                 
                int main()
                {
                    byte stdbyte;
                    stdbyte = std::byte(0);
                    byte *arr = new std::byte[2];
                    arr[0] = std::byte(0x2a);
                 
                    cout << "Hello World!" << endl;
                    return 0;
                }
                

                Why don't you try this and see if it works?

                1 Reply Last reply
                4
                • K kenchan

                  @Engelard
                  hmm?? looks like you have another problem somewhere.
                  Can you show us your pro file?
                  Can you show us a screen shot of your kits panel for the kit you are currently using again please?
                  Can you show us a screen shot the qt versions panel and the compilers panel again please?
                  Can can you show a screen shot of the compiler output when you compile your code with the std::byte declaration please?

                  Thank you

                  EngelardE Offline
                  EngelardE Offline
                  Engelard
                  wrote on last edited by
                  #29
                  This post is deleted!
                  1 Reply Last reply
                  0
                  • EngelardE Offline
                    EngelardE Offline
                    Engelard
                    wrote on last edited by
                    #30

                    Seems the problem was in old build directory. After complete deletion of it - program finally compiles:

                    alt text

                    DAMN it was hard and so long. New features of new C++17 in Qt cost so much...

                    K 1 Reply Last reply
                    0
                    • EngelardE Engelard

                      Seems the problem was in old build directory. After complete deletion of it - program finally compiles:

                      alt text

                      DAMN it was hard and so long. New features of new C++17 in Qt cost so much...

                      K Offline
                      K Offline
                      kenchan
                      wrote on last edited by
                      #31

                      @Engelard
                      Yes, that is what I suspected was the problem.
                      Glad you finally got it working.

                      1 Reply Last reply
                      2

                      • Login

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