Provide dummy operators to fix linker errors with msvc
Christian Ehrlicher
Ch.Ehrlicher at gmx.de
Thu Nov 3 20:22:01 GMT 2005
Hi,
Because msvc needs a fully instantiated class when this class is
exported (see '[Patch] fix compile kdecore with msvc'), we need a dummy
comparator== and a dummy function qHash(class). Qt is doing the same
thing for operator== in qglobal.h.
---------------------------8<--------------
#ifdef K_FULL_TEMPLATE_EXPORT_INSTANTIATION
# define K_DUMMY_COMPARISON_OPERATOR(C) \
bool operator==(const C&) const { \
qWarning(#C"::operator==(const "#C"&) was called"); \
return false; \
}
# define K_DUMMY_QHASH_OPERATOR(C) \
inline uint qHash(const C) { \
qWarning("inline uint qHash(const "#C") was called"); \
return 0; \
}
#else
# define K_DUMMY_COMPARISON_OPERATOR(C)
# define K_DUMMY_QHASH_OPERATOR(C)
#endif
---------------------------8<--------------
If you want, you can additional mask this with
#ifdef MAKE_KFOO_LIB
K_FULL_TEMPLATE_EXPORT_INSTANTIATION(KFooClass)
K_DUMMY_QHASH_OPERATOR(KFooClass)
#endif
So nobody using this lib can access those functions and gcc won't care
because K_FULL_TEMPLATE_EXPORT_INSTANTIATION isn't set...
Christian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20051103/4a0fee6b/attachment.sig>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 250 bytes
Desc: OpenPGP digital signature
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20051103/4a0fee6b/attachment-0001.sig>
More information about the kde-core-devel
mailing list