Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-69170

Update types in qglobal to use types from cstdint

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Won't Do
    • Icon: P5: Not important P5: Not important
    • None
    • 5.11.1
    • Core: Other
    • None

      Currently we are using in64_t, uin64_t, ... from cstdint in our framework. With this we currently get sometimes compile error with clang, because qint64 != int64_t

      Example output of clang:

      error: conversion from 'long' to 'const QJsonValue' is ambiguous
              jsonObject["key"] = std::numeric_limits<int64_t>::max();
                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      /path_to_qt/Qt/5.11.1/gcc_64/include/QtCore/qjsonvalue.h:77:5: note: candidate constructor
          QJsonValue(bool b);
          ^
      /path_to_qt/Qt/5.11.1/gcc_64/include/QtCore/qjsonvalue.h:78:5: note: candidate constructor
          QJsonValue(double n);
          ^
      /path_to_qt/Qt/5.11.1/gcc_64/include/QtCore/qjsonvalue.h:79:5: note: candidate constructor
          QJsonValue(int n);
          ^
      /path_to_qt/Qt/5.11.1/gcc_64/include/QtCore/qjsonvalue.h:80:5: note: candidate constructor
          QJsonValue(qint64 n);
      

      As you can see int64_t is defined as long in clang, during Qt is using long long for it - both are correct on x64 machines. Reason for difference of clang see here.

      As Qt required C++11 since Qt5.7 we could adjust qglobal.h to just types from cstdint from

      typedef signed char qint8;         /* 8 bit signed */
      typedef unsigned char quint8;      /* 8 bit unsigned */
      typedef short qint16;              /* 16 bit signed */
      typedef unsigned short quint16;    /* 16 bit unsigned */
      typedef int qint32;                /* 32 bit signed */
      typedef unsigned int quint32;      /* 32 bit unsigned */
      #if defined(Q_OS_WIN) && !defined(Q_CC_GNU)
      #  define Q_INT64_C(c) c ## i64    /* signed 64 bit constant */
      #  define Q_UINT64_C(c) c ## ui64   /* unsigned 64 bit constant */
      typedef __int64 qint64;            /* 64 bit signed */
      typedef unsigned __int64 quint64;  /* 64 bit unsigned */
      #else
      #ifdef __cplusplus
      #  define Q_INT64_C(c) static_cast<long long>(c ## LL)     /* signed 64 bit constant */
      #  define Q_UINT64_C(c) static_cast<unsigned long long>(c ## ULL) /* unsigned 64 bit constant */
      #else
      #  define Q_INT64_C(c) ((long long)(c ## LL))               /* signed 64 bit constant */
      #  define Q_UINT64_C(c) ((unsigned long long)(c ## ULL))    /* unsigned 64 bit constant */
      #endif
      typedef long long qint64;           /* 64 bit signed */
      typedef unsigned long long quint64; /* 64 bit unsigned */
      #endif
      

      too

      typedef int8_t qint8;         /* 8 bit signed */
      typedef uint8_t quint8;      /* 8 bit unsigned */
      typedef int16_t qint16;              /* 16 bit signed */
      typedef uint16_t quint16;    /* 16 bit unsigned */
      typedef int32_t qint32;                /* 32 bit signed */
      typedef uint32_t quint32;      /* 32 bit unsigned */
      typedef int64_t  qint64;            /* 64 bit signed */
      typedef uint64_t  quint64;  /* 64 bit unsigned */
      

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Unassigned Unassigned
            EliteScience Heiko Thiel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes