Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. IDC generates a wrong IDL type for long long C++ type
QtWS25 Last Chance

IDC generates a wrong IDL type for long long C++ type

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
7 Posts 3 Posters 1.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Titi
    wrote on last edited by
    #1

    The background :

    • Win 7 Professional 64 bits
    • MS VisualStudio 2015 professional
    • QT 5.7 (precompiled version for MSVC2015-x64)

    In a C++ DLL project x64 I use a class derived from QAxFactory to create a COM component. In the associated class (ViewerAx) I declare a method called create as follows

    class ViewerAx : public QObject
    {
    Q_OBJECT
    ...

    public slots:

    void create(long long hParentWnd, int lang);
    ...
    }

    The moc generated file seems right according to the first argument type

    // slots: parameters
    QMetaType::Void, QMetaType::LongLong, QMetaType::Int, 9, 10,

    void ViewerAx::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
    {
    if (_c == QMetaObject::InvokeMetaMethod) {
    ViewerAx *_t = static_cast<ViewerAx *>(_o);
    Q_UNUSED(_t)
    switch (_id) {
    case 0: _t->create((reinterpret_cast< long long()>(_a[1])),(reinterpret_cast< int()>(_a[2]))); break;
    ...
    }

    but the type of this argument is wrong in the IDL file generated by running the following command
    idc ViewerAx.dll /idl ViewerAx.idl

    as shown below
    [id(1)] void create([in] CY p_hParentWnd, [in] int p_lang);

    The long long argument (int 64 bits in C++) has been translated into the CY (Currency) IDL type and when using this COM interface in a C# project the argument type becomes "decimal" leading to type mismatch.

    Replacing CY with int64 in the idl file solves the problem.

    So is there a way to make idc generate the right IDL type for 64 bits C++ types or is it a bug ?

    1 Reply Last reply
    0
    • hskoglundH Offline
      hskoglundH Offline
      hskoglund
      wrote on last edited by
      #2

      Hi, just checked Qt's source (the type_map[] table in qaxserver.cpp, line 497) and indeed it's a bug :-(

      (Actually the code was correct 20 years ago but since then Microsoft has changed from using Currency to the hyper data type for long long data in COM. But simpler would be just to use int64 as you say.)

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        @hskoglund since you know more about that, can you open a report so it might get fixed ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        hskoglundH 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          @hskoglund since you know more about that, can you open a report so it might get fixed ?

          hskoglundH Offline
          hskoglundH Offline
          hskoglund
          wrote on last edited by
          #4

          @SGaist You mean opening a QTBug? Good idea, I'm on it :-)

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Yup that's that !

            Since you also know the solution, you might want to consider submitting the bug fix ;)

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            hskoglundH 1 Reply Last reply
            0
            • SGaistS SGaist

              Yup that's that !

              Since you also know the solution, you might want to consider submitting the bug fix ;)

              hskoglundH Offline
              hskoglundH Offline
              hskoglund
              wrote on last edited by
              #6

              @SGaist https://bugreports.qt.io/browse/QTBUG-55900

              1 Reply Last reply
              1
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Thanks !

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved