[SOLVED]Finding out CPU architecture programmatically using Qt?
Is there a way to find out CPU architecture (e.g ARM / x86) using Qt ?
Take a look at "Q_PROCESSOR_*":http://qt-project.org/doc/qt-5.0/qtcore/qtglobal.html#Q_PROCESSOR_X86
dcortesi last edited by
Class QSysInfo is what you need.
Note this can be tricky since not all members are defined in all platforms (a design error I think; they should return some kind of null value for all cases). In Python I used it this way:
from PyQt4.QtCore import QSysInfo
junk = QSysInfo.WindowsVersion
self.osType = 'Win'
except: # that static var does not exist, so,
junk = QSysInfo.MacintoshVersion
self.osType = 'Mac'
except: # that doesn't exist either, ergo:
self.osType = 'Linux'
Thanks for the replies.
Are the Q_PROCESSOR_* macros available in Qt 4.8? I didn't find it in Qt docs for 4.8 ?
I'm actually afraid they aren't, but you should be able to simply add "qcompilerdetection.h":http://qt.gitorious.org/qt/qtbase/blobs/stable/src/corelib/global/qprocessordetection.h to your project, which will set Q_PROCESSOR_* (or just pick the required definitions from there).
Thanks Lukas! I will try doing that.
This worked for me:
@#if defined(arm) || defined(__TARGET_ARCH_ARM) || defined(_M_ARM)
//code for target
Please mark the post as solved .
[quote author="nikCoder" date="1359704859"]Please mark the post as solved.[/quote]
You can do so by editing your initial post and change the title to '[Solved] ...'. There is unfortunetly no automatism for this yet.