IDC generates a wrong IDL type for long long C++ type
-
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.idlas 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 ?
-
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.)
-
Hi,
@hskoglund since you know more about that, can you open a report so it might get fixed ?
-
Hi,
@hskoglund since you know more about that, can you open a report so it might get fixed ?
-
Yup that's that !
Since you also know the solution, you might want to consider submitting the bug fix ;)
-
Yup that's that !
Since you also know the solution, you might want to consider submitting the bug fix ;)
-
Thanks !