On 25/8/23 14:11, Cristian Adam via Development wrote:
The other way of fixing this is by using ... macros. The article at c++ - Importing 
inline functions in MinGW - Stack 
Overflow<https://stackoverflow.com/questions/11546403/importing-inline-functions-in-mingw>
  mentions using inline in the class declaration.

Their example works fine with both GCC MinGW and Clang MinGW. Visual C++ is 
also fine:

#ifdef _WIN32
#define Q_EXPORT_INLINE inline
#else
#define Q_EXPORT_INLINE
#endif


class __declspec(dllimport) MyClass {
public:
     Q_EXPORT_INLINE int myFunc2();
     Q_EXPORT_INLINE int myFunc1();
};

inline int MyClass::myFunc2(void) {
     return myFunc1();
}

inline int MyClass::myFunc1(void) {
     return 0;
}


[...]

The main deterrent to not fix it like the qstring.h patch[1] is the churn caused by changing many lines, in many files, right?

But if affected code is going to be changed anyway to fix it with macros, it makes more sense to fix it like [1]; if you're changing those lines, may as well adhere to more standard guidelines: inline keyword is only used on function declaration and _not_ the definition.


My 2p's.

[1] https://codereview.qt-project.org/c/qt/qtbase/+/498739


Regards,
Ahmad Samir

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

-- 
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development

Reply via email to