Wednesday, April 6, 2011

How to Overcome Errors Thrown by mmsystem.h

Hi,

I am not able to get out of these simple bugs, but would be great full if some one could answer to weed out from these errors. I included windows.h and some other necessary headers but couldn't able get out of it.

Snippet of errors:

error C2146: syntax error : missing ';' before identifier 'MMVERSION' 
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int error C4430: missing type specifier - int assumed. Note: C++ does not support default-int error C2143: syntax error : missing ';' before '*' 
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int error C2146: syntax error : missing ';' before identifier 'ms' 
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

Thanks In Advance

From stackoverflow
  • Look in mmsystem.h, lines 112 and 113:

    #ifdef _WIN32
    typedef UINT        MMVERSION;  /* major (high byte), minor (low byte) */
    

    So be sure to include windows.h befor including mmsystem.h, and if it does not help, try #defineing _WIN32 manually.

    Tadmas : Usually all you need to do is #define WIN32 and the headers will take care of it for you.
  • To expand on Anton's answer: windows.h #defines UINT to be unsigned int. That's a C macro define, not a typedef. If you #include windows.h before you #include mmsystem.h the line he points to will be read as:

    typedef unsigned int MMVERSION;
    

    However, if you do it the wrong way 'round, then UINT will expand to nothing, and that line will become:

    typedef MMVERSION;
    

    That isn't valid C++ and you will get a parse error. Which is exactly what you're getting.

0 comments:

Post a Comment