Programmatically determine if processor is 64-bit using Qt code
-
wrote on 1 Nov 2012, 21:05 last edited by
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!
-
wrote on 1 Nov 2012, 22:15 last edited by
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 -
wrote on 1 Nov 2012, 23:08 last edited by
[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.
-
wrote on 2 Nov 2012, 10:02 last edited by
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:-)
-
wrote on 2 Nov 2012, 14:08 last edited by
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 :) -
wrote on 14 Apr 2021, 16:52 last edited by
Use:
QSysInfo::buildAbi();
Returns something like
x86_64-little_endian-llp64
ori386-little_endian-ilp32
-
wrote on 14 Apr 2021, 17:28 last edited by JoeCFD
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