[Qt-interest] 64-bit conditional compile
Andre Somers
andre at familiesomers.nl
Wed May 12 08:47:54 CEST 2010
On 12-5-2010 4:07, Berry Octave wrote:
> Le mardi 11 mai 2010, vous avez écrit
>
>> What is the Qt way to conditionally compile for 64-bit or 32-bit
>> architectures?
>>
>> qglobal.h has definitions for Q_WS_MAC64 and Q_OS_WIN64, but I don't
>> see anything for generic 64-bit compile.
>>
>> Thanks!
>>
>> John Weeks
>>
>> WaveMetrics, Inc.
>> Phone (503) 620-3001
>> Fax (503) 620-6754
>> email support at WaveMetrics.com
>>
> A trick would be to use the pointer size.
>
> if (sizeof(void *) == 4)
> // Do 32bits stuff
>
> if (sizeof(void *) == 8)
> // Do 64 bits stuff.
>
> Regards
> Berry Octave
>
That is not really a conditional compile, I'd say. That is a runtime
evaluation, which can be expensive if you do it often.
What I currently do is just define a variable in my project by adding it
to the qmake command (very originally called ARCH), and use that in my
.pro file to do conditional compilation and set defines to use in the code.
André
More information about the Qt-interest-old
mailing list