Solved Why no std::byte in qt?!!
-
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).
-
@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. -
@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',
-
@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?:
And then. Where and for what exactly file should i looking at? Can i add same compiler from my VS2017?
-
-
-
Can you show us what kit are you building with? see image below:
-
@VRonin I just added first manual compiler, which from folder of my VS2017 Community, still it says that byte is not part of std.
Here it is:
Did i did that correct?
-
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:
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?
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
-
@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.
-
@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?
- Did you
-
@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.
-
@Engelard said in Why no std::byte in qt?!!:
CONFIG += c++17
QMAKE_CXXFLAGS += -std:c++17Please try
CONFIG +=c++1z
This works for me with Visual Studio 2017 compiler.
-
@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.
-
@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).
This is the CPU instruction set. Intel processors use amd64, so it's correct.
lol
- Did you
-
@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++17Please 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.
-
@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:
-
Even restart of Qt don't help, what's wrong...
-
@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
-
@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?