[Development] QMetaType and type aliases for primitive types

Alberto Mardegan mardy at users.sourceforge.net
Sun May 9 08:55:36 CEST 2021


Hi Tiago,

On 08/05/21 18:47, Thiago Macieira wrote:
> And the problem is that they *do* depend on the CPU architecture. long changes 
> size depending on OS and pointer size.

yes, I knew that long changes size depending on the architecture, but:

> As far as I am concerned, the fact that 
> int64_t, size_t and ptrdiff_t sometimes (not always!) use long is a 
> misfeature. Those decisions were made in the early 90s by C, before long long 
> existed in the standard, and before C++ with overloads and ABI became an 
> important thing. So we carry some legacy.

what I didn't know (or wasn't fully aware of the consequences) is that
the {,u}intX_t types are just typedefs.

>> Interestingly, I'm seeing this on amd64 only; it seems that on armhf
>> everything is working fine. Could it be a bug with the compiler?
> 
> No, that's because there the compiler defines int64_t as a different type 
> (long long) because long is only 32-bit.

I see, now it makes sense. It looks like so far I managed to workaround
the problem by changing int64_t to qint64 in a handful of places only,
and changing the metatype registration to:

   qRegisterMetaType<qint64>("int64_t");
   qRegisterMetaType<quint64>("uint64_t");

which makes Q_PROPERTY use the right type when I declare them as
int64_t. Though maybe I'll eventually get rid of int64_t completely...

Ciao and thanks,
  Alberto

-- 
http://www.mardy.it - Geek in un lingua international


More information about the Development mailing list