Qt Creator clang weak-vtable warnings and __declspec(dllexport)
-
I keep getting a weak-vtable warning (<classname> has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit) on any of my classes which are declared like this
class __declspec(dllexport) Example : public QDialog { Q_OBJECT public: virtual ~Example();
but the class has an out-of-line export method.
If I change the dllexport to dllimport the message goes away.
A note: The actual declspec is embedded in a macro, so that the header can be used by clients or the implementation, but I don't particularly want to do something like
#ifdef __clang
in case this project ends up getting compiled with clang in the future.So how do I et it not to produce the warning in this case? is it a problem with the version of clang Qt uses?
-
@thosrtanner
Hi,
As an addition to @SGaist's link, also make sureExample::~Example()
is defined. While the standard requires all virtual methods declarations be defined some compilers and linkers will ignore that and will not generate vtable entries for undefined methods, thus builds will silently succeed.Kind regards.
-