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.3k 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.
  • E Engelard
    9 Oct 2018, 01:49

    Situation:
    For last 3 hours i tried to figure out whats wrong with my code which i successfully ported in Qt. Now i find reason - qt betrayed me.

    I brought my code from VS to Qt. I runned it, everything seems fine,no errors in compile/runtime but program did'nt succeed. Then for next 3 hours i was looking where i made a mistake and found it.

    In vs i had

    using namespace std;
    

    for nicer code. But in Qt i forgot about that. So, as i understand Qt have it's own, embedded 'byte' type. And when i tried add prefix to my code like 'std::byte' compiler tells me "byte is not part of standard library".

    Wut? And then i goes to description of type, found that this type comes from <cstddef> so i included it, but nothing changed, still have only wrong byte from qt which is different.

    Tried to replace with QByteArray, but ofcourse it not working. Because i need somehow to use proper one: https://en.cppreference.com/w/cpp/types/byte

    J Offline
    J Offline
    jsulm
    Lifetime Qt Champion
    wrote on 9 Oct 2018, 04:52 last edited by
    #3

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

    qt betrayed me

    Sorry, but before complaining about Qt you should check what std::byte actually is.
    As @kenchan said std::byte is part of C++ standard library (as everything in std namespace).
    Furthermore std::byte is part of C++17 standard, that means: you need a C++ compiler supporting C++17.
    See https://en.cppreference.com/w/cpp/types/byte
    What compiler do you use?
    This problem is completely unrelated to Qt.

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

    E 2 Replies Last reply 9 Oct 2018, 13:34
    8
    • E Engelard
      9 Oct 2018, 01:49

      Situation:
      For last 3 hours i tried to figure out whats wrong with my code which i successfully ported in Qt. Now i find reason - qt betrayed me.

      I brought my code from VS to Qt. I runned it, everything seems fine,no errors in compile/runtime but program did'nt succeed. Then for next 3 hours i was looking where i made a mistake and found it.

      In vs i had

      using namespace std;
      

      for nicer code. But in Qt i forgot about that. So, as i understand Qt have it's own, embedded 'byte' type. And when i tried add prefix to my code like 'std::byte' compiler tells me "byte is not part of standard library".

      Wut? And then i goes to description of type, found that this type comes from <cstddef> so i included it, but nothing changed, still have only wrong byte from qt which is different.

      Tried to replace with QByteArray, but ofcourse it not working. Because i need somehow to use proper one: https://en.cppreference.com/w/cpp/types/byte

      J Offline
      J Offline
      J.Hilk
      Moderators
      wrote on 9 Oct 2018, 04:58 last edited by
      #4

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

      In vs i had

      using namespace std;
      

      for nicer code. But in Qt i forgot about that.

      And thats one of the reasons I don't use using namespace at least globaly for a class, one should always be certain what one is actually referencing/using

      That makes me also a non user of auto, if I can avoid it.


      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.

      J 1 Reply Last reply 9 Oct 2018, 05:01
      6
      • J jsulm
        9 Oct 2018, 04:52

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

        qt betrayed me

        Sorry, but before complaining about Qt you should check what std::byte actually is.
        As @kenchan said std::byte is part of C++ standard library (as everything in std namespace).
        Furthermore std::byte is part of C++17 standard, that means: you need a C++ compiler supporting C++17.
        See https://en.cppreference.com/w/cpp/types/byte
        What compiler do you use?
        This problem is completely unrelated to Qt.

        E Offline
        E Offline
        Engelard
        wrote on 9 Oct 2018, 13:34 last edited by Engelard 10 Sept 2018, 13:38
        #5

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

        This problem is completely unrelated to Qt.

        It works in VS, and not working in Qt. And you telling me that "completely unrelated"? How your argument should work?

        1 Reply Last reply
        0
        • J Offline
          J Offline
          JohanSolo
          wrote on 9 Oct 2018, 13:36 last edited by
          #6

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

          It works in VS, and not working in Qt. And you telling me that "completely unrelated"? How your argument should work?

          Well, Qt is no compiler... it's a framework. Therefore the argument holds.

          `They did not know it was impossible, so they did it.'
          -- Mark Twain

          E 1 Reply Last reply 9 Oct 2018, 13:40
          4
          • J jsulm
            9 Oct 2018, 04:52

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

            qt betrayed me

            Sorry, but before complaining about Qt you should check what std::byte actually is.
            As @kenchan said std::byte is part of C++ standard library (as everything in std namespace).
            Furthermore std::byte is part of C++17 standard, that means: you need a C++ compiler supporting C++17.
            See https://en.cppreference.com/w/cpp/types/byte
            What compiler do you use?
            This problem is completely unrelated to Qt.

            E Offline
            E Offline
            Engelard
            wrote on 9 Oct 2018, 13:39 last edited by
            #7

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

            What compiler do you use?

            alt text

            1 Reply Last reply
            0
            • J JohanSolo
              9 Oct 2018, 13:36

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

              It works in VS, and not working in Qt. And you telling me that "completely unrelated"? How your argument should work?

              Well, Qt is no compiler... it's a framework. Therefore the argument holds.

              E Offline
              E Offline
              Engelard
              wrote on 9 Oct 2018, 13:40 last edited by
              #8

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

              Well, Qt is no compiler... it's a framework. Therefore the argument holds.

              I don't understand. Each IDA must have it's own compiler, no?

              K 1 Reply Last reply 9 Oct 2018, 13:49
              0
              • E Offline
                E Offline
                Engelard
                wrote on 9 Oct 2018, 13:41 last edited by Engelard 10 Sept 2018, 13:46
                #9

                Just tell me what should i do to be able to use std::byte in qt...

                P.S. this topic for some reason became 'auto topic', but this keyword wont work for my case because it can't convert in proper 'raw byte' type because there is no such thing in my Qt(yet).

                V 1 Reply Last reply 9 Oct 2018, 14:31
                0
                • E Engelard
                  9 Oct 2018, 13:40

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

                  Well, Qt is no compiler... it's a framework. Therefore the argument holds.

                  I don't understand. Each IDA must have it's own compiler, no?

                  K Offline
                  K Offline
                  kenchan
                  wrote on 9 Oct 2018, 13:49 last edited by kenchan 10 Sept 2018, 15:10
                  #10

                  @Engelard
                  No, the Qt IDE is not a compiler, it provides you with the ability to use whatever compiler you have installed and is compatible with the version of Qt you are using.
                  In the case of the VS IDE it just happens to be provided by Microsoft and they also provide their own compiler as part of the package. That is just the way it is!

                  If you want to use the c++17 features in Qt Creator you must tell the compiler you want to use it by putting CONFIG += c++17 in your pro file.
                  EDIT:
                  Another way to make it use the c++17 features is to add QMAKE_CXXFLAGS += -std:c++17 this should be equivalent to the above if you use the correct compiler.
                  I think it will only work the the 15.0 compiler, I tried it with the 14.0 compiler and the complier did not like it. I don't use Qt with the 15.0 version yet so I can't test that.

                  E 1 Reply Last reply 9 Oct 2018, 15:56
                  6
                  • E Engelard
                    9 Oct 2018, 13:41

                    Just tell me what should i do to be able to use std::byte in qt...

                    P.S. this topic for some reason became 'auto topic', but this keyword wont work for my case because it can't convert in proper 'raw byte' type because there is no such thing in my Qt(yet).

                    V Offline
                    V Offline
                    VRonin
                    wrote on 9 Oct 2018, 14:31 last edited by
                    #11

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

                    what should i do to be able to use std::byte in qt

                    Just chose as a compiler VS 2017.3 [P2] or later (i.e. the compiler 15.0)

                    Each IDA must have it's own compiler, no?

                    Absolutely not.

                    this topic for some reason became 'auto topic',

                    Forked to https://forum.qt.io/topic/95412/rants-about-auto

                    "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                    ~Napoleon Bonaparte

                    On a crusade to banish setIndexWidget() from the holy land of Qt

                    1 Reply Last reply
                    3
                    • K kenchan
                      9 Oct 2018, 13:49

                      @Engelard
                      No, the Qt IDE is not a compiler, it provides you with the ability to use whatever compiler you have installed and is compatible with the version of Qt you are using.
                      In the case of the VS IDE it just happens to be provided by Microsoft and they also provide their own compiler as part of the package. That is just the way it is!

                      If you want to use the c++17 features in Qt Creator you must tell the compiler you want to use it by putting CONFIG += c++17 in your pro file.
                      EDIT:
                      Another way to make it use the c++17 features is to add QMAKE_CXXFLAGS += -std:c++17 this should be equivalent to the above if you use the correct compiler.
                      I think it will only work the the 15.0 compiler, I tried it with the 14.0 compiler and the complier did not like it. I don't use Qt with the 15.0 version yet so I can't test that.

                      E Offline
                      E Offline
                      Engelard
                      wrote on 9 Oct 2018, 15:56 last edited by
                      #12

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

                      I think it will only work the the 15.0 compiler, I tried it with the 14.0 compiler and the complier did not like it. I don't use Qt with the 15.0 version yet so I can't test that.

                      Did'nt work out((

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

                      Just chose as a compiler VS 2017.3 [P2] or later (i.e. the compiler 15.0)

                      Which one should i choose?:

                      alt text

                      And then. Where and for what exactly file should i looking at? Can i add same compiler from my VS2017?

                      V 1 Reply Last reply 9 Oct 2018, 17:23
                      0
                      • E Engelard
                        9 Oct 2018, 15:56

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

                        I think it will only work the the 15.0 compiler, I tried it with the 14.0 compiler and the complier did not like it. I don't use Qt with the 15.0 version yet so I can't test that.

                        Did'nt work out((

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

                        Just chose as a compiler VS 2017.3 [P2] or later (i.e. the compiler 15.0)

                        Which one should i choose?:

                        alt text

                        And then. Where and for what exactly file should i looking at? Can i add same compiler from my VS2017?

                        V Offline
                        V Offline
                        VRonin
                        wrote on 9 Oct 2018, 17:23 last edited by
                        #13

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

                        Did'nt work out((

                        What did you do?

                        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                        ~Napoleon Bonaparte

                        On a crusade to banish setIndexWidget() from the holy land of Qt

                        E 1 Reply Last reply 9 Oct 2018, 17:57
                        0
                        • V VRonin
                          9 Oct 2018, 17:23

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

                          Did'nt work out((

                          What did you do?

                          E Offline
                          E Offline
                          Engelard
                          wrote on 9 Oct 2018, 17:57 last edited by Engelard 10 Sept 2018, 17:58
                          #14

                          @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 K 2 Replies Last reply 10 Oct 2018, 13:16
                          0
                          • V Offline
                            V Offline
                            VRonin
                            wrote on 9 Oct 2018, 18:03 last edited by
                            #15

                            Can you show us what kit are you building with? see image below:
                            0_1539108183391_Capture.png

                            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                            ~Napoleon Bonaparte

                            On a crusade to banish setIndexWidget() from the holy land of Qt

                            E 1 Reply Last reply 9 Oct 2018, 22:04
                            0
                            • V VRonin
                              9 Oct 2018, 18:03

                              Can you show us what kit are you building with? see image below:
                              0_1539108183391_Capture.png

                              E Offline
                              E Offline
                              Engelard
                              wrote on 9 Oct 2018, 22:04 last edited by
                              #16

                              @VRonin I just added first manual compiler, which from folder of my VS2017 Community, still it says that byte is not part of std.

                              alt text

                              Here it is:

                              alt text

                              Did i did that correct?

                              V 1 Reply Last reply 10 Oct 2018, 06:42
                              0
                              • E Offline
                                E Offline
                                Engelard
                                wrote on 9 Oct 2018, 22:22 last edited by Engelard 10 Sept 2018, 22:38
                                #17

                                Oh and in the Kits i just now noticed, for some reason there is compilers for amd chosen, when i have normal for intel i suppose in my VS. And i can't change it, when i press manage - it's simply throw me in to compilers tab so i don't know how to change it:

                                alt text

                                AND. i just now added one more custom compiler, also from VS2017 but 64 version, since i have x64 CPU and windows, maybe should be proper one, am i right?

                                alt text

                                Only one thing (as i understand) left to do. Is apply compiler which i chose in 'compilers' tab, because there is still my old as you can see from screenshot

                                alt text

                                J K 2 Replies Last reply 10 Oct 2018, 04:47
                                0
                                • E Engelard
                                  9 Oct 2018, 22:22

                                  Oh and in the Kits i just now noticed, for some reason there is compilers for amd chosen, when i have normal for intel i suppose in my VS. And i can't change it, when i press manage - it's simply throw me in to compilers tab so i don't know how to change it:

                                  alt text

                                  AND. i just now added one more custom compiler, also from VS2017 but 64 version, since i have x64 CPU and windows, maybe should be proper one, am i right?

                                  alt text

                                  Only one thing (as i understand) left to do. Is apply compiler which i chose in 'compilers' tab, because there is still my old as you can see from screenshot

                                  alt text

                                  J Offline
                                  J Offline
                                  jsulm
                                  Lifetime Qt Champion
                                  wrote on 10 Oct 2018, 04:47 last edited by jsulm 10 Oct 2018, 04:55
                                  #18

                                  @Engelard "How your argument should work?" - easy. You should understand the difference between a compiler, an IDE and a framework. Qt is a C++ framework (not a compiler), QtCreator is an IDE which supports many different compilers, but does not contain own compilers. C++standard library (std::*) comes as part of the compiler and NOT Qt, that's why it is "completely unrelated to Qt". So, as already explained by others you need a compiler supporting C++2017 and activate C++2017 supports in the pro file (not sure it is needed with Microsoft compilers).

                                  Didn't QtCreator auto-detect your VS2017 compiler? Usually there is no need to configure compilers manually. The 15.0 is already the C++ compiler from VS2017, why do you add the compiler manually? Does it now work with your "Desktop Qt 5.10.1 MSVC2017 64bit2" Kit and autodetected VS2017 compiler?

                                  One note: an IDE does not have to contain any compilers. Microsoft Compilers can be installed and used without Visual Studio. The reasons are: it must be possible to use compilers without a huge IDE (for example in a continuous integration system) and many IDEs (like QtCreator) support different compilers which come from different companies or are open source. QtCreator, for example, supports Microsoft Compilers and MinGW on Windows. Qt Online Installer for Windows provides the possibility to install MinGW as it is Open Source. Microsoft compilers on the other hand can't be provided by Qt Online Installer as this not allowed by Microsoft.

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

                                  1 Reply Last reply
                                  5
                                  • E Engelard
                                    9 Oct 2018, 22:04

                                    @VRonin I just added first manual compiler, which from folder of my VS2017 Community, still it says that byte is not part of std.

                                    alt text

                                    Here it is:

                                    alt text

                                    Did i did that correct?

                                    V Offline
                                    V Offline
                                    VRonin
                                    wrote on 10 Oct 2018, 06:42 last edited by
                                    #19

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

                                    "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                                    ~Napoleon Bonaparte

                                    On a crusade to banish setIndexWidget() from the holy land of Qt

                                    E 1 Reply Last reply 10 Oct 2018, 15:05
                                    1
                                    • E Engelard
                                      9 Oct 2018, 22:22

                                      Oh and in the Kits i just now noticed, for some reason there is compilers for amd chosen, when i have normal for intel i suppose in my VS. And i can't change it, when i press manage - it's simply throw me in to compilers tab so i don't know how to change it:

                                      alt text

                                      AND. i just now added one more custom compiler, also from VS2017 but 64 version, since i have x64 CPU and windows, maybe should be proper one, am i right?

                                      alt text

                                      Only one thing (as i understand) left to do. Is apply compiler which i chose in 'compilers' tab, because there is still my old as you can see from screenshot

                                      alt text

                                      K Offline
                                      K Offline
                                      kshegunov
                                      Moderators
                                      wrote on 10 Oct 2018, 08:57 last edited by
                                      #20

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

                                      Read and abide by the Qt Code of Conduct

                                      E 1 Reply Last reply 10 Oct 2018, 15:09
                                      5
                                      • E Engelard
                                        9 Oct 2018, 17:57

                                        @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
                                        kkoehne
                                        Moderators
                                        wrote on 10 Oct 2018, 13:16 last edited by
                                        #21

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

                                        Director R&D, The Qt Company

                                        1 Reply Last reply
                                        2
                                        • E Engelard
                                          9 Oct 2018, 17:57

                                          @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 10 Oct 2018, 14:22 last edited by kenchan 10 Oct 2018, 14:32
                                          #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.

                                          E 1 Reply Last reply 10 Oct 2018, 15:16
                                          4

                                          12/31

                                          9 Oct 2018, 15:56

                                          • Login

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