Results 1 to 6 of 6

Thread: invalid use of incomplete type 'struct MSG'

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2011
    Posts
    8
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default invalid use of incomplete type 'struct MSG'

    Hi

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

    declaration in QtClass.h
    Qt Code:
    1. virtual bool winEvent(MSG *message, long *result);
    To copy to clipboard, switch view to plain text mode 

    declaration in QtClass.cpp
    Qt Code:
    1. bool GUI::winEvent(MSG *message, long *result)
    2. {
    3. switch(message->message) // problem with that line
    4. {
    5. case Qt::Key_0 :
    6. //do something...
    7.  
    8. }
    9. return false;
    10. }
    To copy to clipboard, switch view to plain text mode 

    And my error log is:
    Qt Code:
    1. gui.cpp:21:19: error: invalid use of incomplete type 'struct MSG'
    2. ../../../../Qt/4.7.3/include/QtGui/../../src/gui/kernel/qwindowdefs_win.h:117:16: error: forward declaration of 'struct MSG'
    3. gui.cpp:25:27: error: invalid use of incomplete type 'struct MSG'
    4. ../../../../Qt/4.7.3/include/QtGui/../../src/gui/kernel/qwindowdefs_win.h:117:16: error: forward declaration of 'struct MSG'
    To copy to clipboard, switch view to plain text mode 

    What i did wrong?

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,391
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: invalid use of incomplete type 'struct MSG'

    Try to #include <windows.h> in .cpp file (after all other includes).

  3. The following user says thank you to stampede for this useful post:

    libed (18th July 2011)

  4. #3
    Join Date
    Nov 2010
    Posts
    315
    Thanked 53 Times in 51 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: invalid use of incomplete type 'struct MSG'

    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).

  5. The following user says thank you to MarekR22 for this useful post:

    libed (18th July 2011)

  6. #4
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,391
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: invalid use of incomplete type 'struct MSG'

    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) .

  7. #5
    Join Date
    Jul 2011
    Posts
    8
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: invalid use of incomplete type 'struct MSG'

    Thank You guy's. Now its working fine.

  8. #6
    Join Date
    Feb 2019
    Posts
    1
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Red face Re: invalid use of incomplete type 'struct MSG'

    Quote Originally Posted by stampede View Post
    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

Similar Threads

  1. QSql - incomplete type 'struct QVariant'
    By UltramaticOrange in forum Newbie
    Replies: 2
    Last Post: 5th October 2010, 19:07
  2. Replies: 9
    Last Post: 29th August 2010, 14:30
  3. error: invalid use of incomplete type 'struct QMetaEnum'
    By dyngoman in forum Qt Programming
    Replies: 3
    Last Post: 12th March 2010, 13:38
  4. Replies: 4
    Last Post: 12th October 2009, 19:36
  5. Replies: 1
    Last Post: 15th October 2007, 14:21

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.