PDA

View Full Version : invalid use of incomplete type 'struct MSG'



libed
18th July 2011, 10:35
Hi

Im working with Eclipse CDT for WIndows with Qt integration plugin. I have a problem with my winEvent() function.

declaration in QtClass.h


virtual bool winEvent(MSG *message, long *result);


declaration in QtClass.cpp


bool GUI::winEvent(MSG *message, long *result)
{
switch(message->message) // problem with that line
{
case Qt::Key_0 :
//do something...

}
return false;
}


And my error log is:


gui.cpp:21:19: error: invalid use of incomplete type 'struct MSG'
../../../../Qt/4.7.3/include/QtGui/../../src/gui/kernel/qwindowdefs_win.h:117:16: error: forward declaration of 'struct MSG'
gui.cpp:25:27: error: invalid use of incomplete type 'struct MSG'
../../../../Qt/4.7.3/include/QtGui/../../src/gui/kernel/qwindowdefs_win.h:117:16: error: forward declaration of 'struct MSG'


What i did wrong?

stampede
18th July 2011, 11:28
Try to #include <windows.h> in .cpp file (after all other includes).

MarekR22
18th July 2011, 11:36
I would rather say that you have used forward declared structure MSG, so now in cpp you have to include header file with definition of this structure (it is not related at all with windows.h).

stampede
18th July 2011, 11:45
I would rather say that you have used forward declared structure MSG, so now in cpp you have to include header file with definition of this structure
Thats what I meant :)

it is not related at all with windows.h
MSG is defined in windows.h (winuser.h to be precise, but its included in windows.h) ;).

libed
18th July 2011, 12:14
Thank You guy's. Now its working fine.

regatble
21st February 2019, 12:32
Try to #include <windows.h> in .cpp file (after all other includes).

7 years later.... qmultimedia still needed this patch in qt5.12.1 :-) thanks got me through the static build