Error C4430: missing type specifier

I am trying to compile a program with the VS .NET 2005 Beta 2 command-line C++ compiler (cl.exe).  The program uses MFC header files from the latest Microsoft Platform SDK.  The compiler successfully includes all the correct headers, but returns the following error messages:

C:\Program Files\Microsoft Platform SDK\Include\mfc\afxwin1.inl(1034) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files\Microsoft Platform SDK\Include\mfc\afxwin1.inl(1036) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

I checked the lines of code mentioned and found the following:

1033   _AFXWIN_INLINE CMenu::operator==(const CMenu& menu) const
1034       { return ((HMENU) menu) == m_hMenu; }
1035   _AFXWIN_INLINE CMenu::operator!=(const CMenu& menu) const
1036       { return ((HMENU) menu) != m_hMenu; }

Does anybody know of a resolution to this problem



Answer this question

Error C4430: missing type specifier

  • woef22

    I've just doubled checked. In the Windows header files LONG is not a macro it is instead a typedef: it is defined in winnt.h at line 258:

    #ifndef VOID
    #define VOID
    void
    typedef
    char
    CHAR;
    typedef short
    SHORT;
    typedef long
    LONG;
    #endif

    So the only way I can see that you could be hitting this problem is if somehow your program (or some header file you are #include'ing) is defining LONG to be a macro.



  • Khushal

    I am also having the same problem in winnt.h and winbase.h, again, using the latest SDK with the Express VC ++beta (both compiler and target platforms are x86 32-bit, in my case, XP SP2).

    In both cases, line 8806 of winnt.h and line 2722 of winbase.h, the macro LONG is undefined by the time the preprocessor gets there, so the compiler doesn't know what to typedef something to:

    typedef LONG (NTAPI *PVECTORED_EXCEPTION_HANDLER)(
        struct _EXCEPTION_POINTERS *ExceptionInfo
        );


    is preprocessed into

    typedef (__stdcall *PVECTORED_EXCEPTION_HANDLER)(
        struct _EXCEPTION_POINTERS *ExceptionInfo
        );


    and

    typedef LONG (WINAPI *PTOP_LEVEL_EXCEPTION_FILTER)(
        __in struct _EXCEPTION_POINTERS *ExceptionInfo
        );


    is preprocessed into

    typedef (__stdcall *PTOP_LEVEL_EXCEPTION_FILTER)(
             struct _EXCEPTION_POINTERS *ExceptionInfo
        );


    Help, please!

  • BullZhot aka Klaes

    The only real fix for this problem is to edit the header files. Just replace LONG with long.

    Which version of the PSDK are you using The most recent version should have all these problems fixed as we did make a pass through them with the latest compiler.

  • microspectrum

    This should work:

    1033   _AFXWIN_INLINE bool CMenu::operator==(const CMenu& menu) const
    1034       { return ((HMENU) menu) == m_hMenu; }
    1035   _AFXWIN_INLINE bool CMenu::operator!=(const CMenu& menu) const
    1036       { return ((HMENU) menu) != m_hMenu; }



  • AndrewJones

    Thanks, you're right of course. I checked with one of the lead developers of the program and they have confirmed that an old section of the code defines LONG (v) as (v) for some historical reason; I've asked them to look into it regarding compatibility with the new compiler and the standard Platform SDK.

    This code built fine with VC++ 2003 .NET, but that has its own SDK subset and doesn't use the main Platform SDK. Visual C++ Express beta didn't come with the full SDK, so I had to download that and that's when the problem started.

    Anyway, this is clearly not a Microsoft issue, so thanks for your help.

  • Error C4430: missing type specifier