Details
-
Bug
-
Resolution: Duplicate
-
Not Evaluated
-
3.3.1.1
-
None
Description
If i have any class in a header file that uses Q_OBJECT and is inside a #if ... #endif block, it fails to compile, i get errors like this:
unresolved external symbol "public: virtual struct QMetaObject const * __cdecl Widget::metaObject(void)const " (?metaObject@Widget@@UEBAPEBUQMetaObject@@XZ) unresolved external symbol "public: virtual void * __cdecl Widget::qt_metacast(char const *)" (?qt_metacast@Widget@@UEAAPEAXPEBD@Z) unresolved external symbol "public: virtual int __cdecl Widget::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@Widget@@UEAAHW4Call@QMetaObject@@HPEAPEAX@Z) 3 unresolved externals
This issue can be reproduced with this simple example:
//test.h #pragma once #if CUSTOM_WIDGET class Widget : public QWidget { Q_OBJECT public: Widget(QWidget* parent = nullptr); }; #endif
// stdafx.h #include <QtWidgets> #define CUSTOM_WIDGET 1
Commenting Q_OBJECT or #if CUSTOM_WIDGET in test.h it does compile correctly.
I'm testing using:
VS22 Version 17.14.0 Preview 4.0,
Qt Extension 3.3.1.1,
Qt Source 6.6.0,
Windows 10.
Attachments
Issue Links
- duplicates
-
QTVSADDINBUG-855 Q_OBJECT inside a "#if false/#endif" block
-
- In Progress
-