Programmatically determine if processor is 64-bit using Qt code
-
Hi, is there anybody can tell me how to programmaticall determine if the processor is 64-bit or 32-bit by calling some Qt class method. I looked into QSysInfo, but it can only tell OS version.
Thanks!
-
It's purely OS based how this data is acquired.
So you'll need to use different functions based on OS. Those are not provided by Qt.And even with that, you'll get only if OS is 32 or 64-bit, not the processor.
Regards,
Jake -
[quote author="Jake007" date="1351808156"]It's purely OS based how this data is acquired.
So you'll need to use different functions based on OS. Those are not provided by Qt.
[/quote]Jake007 is right. That functionality depends on your OS' native API.
"You may try this link ":http://vcpptips.wordpress.com/tag/computer-is-running-a-32-bit-or-64-bit-os/
The author shows 3 ways to do it in windows.
-
You can check the size of a pointer to find out whether the application is using 32bit or 64bit. That may or may not be what you want to know though:-)
-
bq. It’s purely OS based how this data is acquired.
So you’ll need to use different functions based on OS. Those are not provided by Qt.So, you can use QProcess ;)
On Linux :@uname -m@
and
@arch @return x86_64 if the CPU is 64bit otherwise it returns i386/i586/i686 !
You have the doc !
and... use your imagination :) -
Use:
QSysInfo::buildAbi();
Returns something like
x86_64-little_endian-llp64
ori386-little_endian-ilp32
-
Sprezzatura is right. Check this out.
https://doc.qt.io/archives/qt-5.9/qsysinfo.html#buildAbi
https://doc.qt.io/qt-5/qsysinfo.html#buildAbi