[Qt-interest] Detecting size of datatype with qmake

Robert Hairgrove evorgriahr at hispeed.ch
Sun May 16 09:36:49 CEST 2010


Nikos Chantziaras wrote:
> On 05/16/2010 10:00 AM, Esben Mose Hansen wrote:
>> On Sunday 16 May 2010 04:47:32 Nikos Chantziaras wrote:
>>> Is there a way I could detect the size of datatypes like 'short' and
>>> 'int' with qmake from within the project file?  I am working with a
>>> header file that needs macros like SIZEOF_SHORT and SIZEOF_INT defined.
>>
>> Why not simply use
>>
>> #define SIZEOF_SHORT sizeof(short)
>> #define SIZEOF_INT sizeof(int)
> 
> Because those macros are used like this:
> 
>   #if SIZEOF_INT == 4
>     typedef int hix_int32;
>   // ...
> 
> and the rest of the code uses hix_int32.

Qt has those types built in, i.e.: qint16, qint32 and qint64 along with 
their unsigned varieties (and many more). Look in the Qt docs and search 
for one of these types which are defined in QGlobal.h.



More information about the Qt-interest-old mailing list