none
zmouse.h and prsht.h errors in my projects that #define _AFXDLL... doesn't happen in ones that don't -- happens in BOTH my projects, no clue why

    Question

  • Hello all,

    I am having some issues with a few of my projects at work here. I have one which is a service using the afx dll and one which is a mfc project and also includes the afx dll. The reason I am pointing out that the afx dll is included is that I have a project which does not use stdafx.dll or #define _AFXDLL and it still compiles fine.

    The weird thing is it worked on Wednesday before the Thanksgiving vacation. I even have an installer that I had created. When I got back to work on Monday, it gives me these 13 errors:

    from zmouse.h:
    Error 1 error C2146: syntax error : missing ';' before identifier 'HwndMSWheel'
    Error 2 error C2433: 'HWND' : 'inline' not permitted on data declarations
    Error 3 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    Error 4 error C2065: 'PUINT' : undeclared identifier
    Error 5 error C2146: syntax error : missing ')' before identifier 'puiMsh_MsgMouseWheel'
    Error 6 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    Error 7 error C2059: syntax error : ')'
    Error 8 error C2143: syntax error : missing ';' before '{'
    Error 9 error C2447: '{' : missing function header (old-style formal list?)

    from prsht.h:
    Error 10 error C2065: 'CALLBACK' : undeclared identifier
    Error 11 error C2065: 'LPFNPSPCALLBACKA' : undeclared identifier
    Error 12 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    Error 13 fatal error C1903: unable to recover from previous error(s); stopping compilation


    I even rebuilt my service from scratch, just copy and pasting code into the new project from my old project. That did not work.

    Like I said before, it worked on Wednesday, I did not touch it for four days, and on Monday I tried to compile it and it would not work. It has the same exact errors no matter which settings I choose in my project settings, or which order my includes are in. I am really at a loss here, and was wondering if anyone else has ran across this.

    I redownloaded and reinstalled the Windows SDK. No worky.

    I have tried to research this extensively but the only advice I see is to include windows.h before zmouse. I am not actively including zmouse, however, so I am not sure why it is erroring.

    Here is my stdafx.h:
    // stdafx.h : include file for standard system include files,
    // or project specific include files that are used frequently, but
    // are changed infrequently
    #pragma once

    #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers

    #define _AFXDLL
    #include afxsock.h
    #include stdio.h
    #include tchar.h
    #include winsock2.h
    #include ws2tcpip.h
    // TODO: reference additional headers your program requires


    It is a pretty basic project which just uses a 3rd party SDK to connect to and control a telephone PBX. I need the socket classes in there to communicate with one of the companies servers.

    Here is the stdafx.h from my other project (uses a SDK to create a video viewer that connects to a DVR out in the field). This project was one I inherited from another developer, then modified it when the clients wanted something added. This one compiled fine as well, until this Thanksgiving weekend.


    // stdafx.h : include file for standard system include files,
    // or project specific include files that are used frequently,
    // but are changed infrequently

    #pragma once

    #define WM_MYTHREADMESSAGE (WM_USER+1)

    #ifndef _SECURE_ATL
    #define _SECURE_ATL 1
    #endif

    #ifndef VC_EXTRALEAN
    #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
    #endif

    // Modify the following defines if you have to target a platform prior to the ones specified below.
    // Refer to MSDN for the latest info on corresponding values for different platforms.
    #ifndef WINVER // Allow use of features specific to Windows XP or later.
    #define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows.
    #endif

    #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
    #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
    #endif

    #ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
    #define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
    #endif

    #ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later.
    #define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE.
    #endif

    #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit

    // turns off MFC's hiding of some common and often safely ignored warning messages
    #define _AFX_ALL_WARNINGS


    #include afxwin.h // MFC core and standard components
    //#include windows.h
    #include afxext.h // MFC extensions

    #include afxdisp.h // MFC Automation classes


    #ifndef _AFX_NO_OLE_SUPPORT
    #include afxdtctl.h // MFC support for Internet Explorer 4 Common Controls
    #endif
    #ifndef _AFX_NO_AFXCMN_SUPPORT
    #include afxcmn.h // MFC support for Windows Common Controls
    #endif // _AFX_NO_AFXCMN_SUPPORT




    I would greatly appreciate any help on this and any more information you may need I will be glad to post.

    I am using Visual Studio 2008
    Windows XP Service pack 3
    .NET Framework 3.5
    Windows SDK 2008 for XP SP 2

    The only thing I can think is that this weekend my computer downloaded an update when I was sleeping... but I have also researched that extensively and could find nothing on it.




    EDIT: I had to take the greater and less than's off my includes so they would show. That is *NOT* a syntax error.
    I'd have a battle of the wits with you... but you are obviously unarmed.
    Friday, December 05, 2008 1:33 PM

Answers

  • File + Open, C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\afxv_w32.h.  Cursor to line #169.  If you see this:

    //#include <windows.h>

    then you destroyed your SDK header files when you did an Edit + Find and Replace.  You could remove the // but there's likely more damage.  Check the file dates in the vc\atlmc\include folder to get an idea how many files are affected.  The only real way to fix this damage is to either copy them from another VS installation or by uninstalling VS, deleting the modified files by hand and reinstalling.

    Hans Passant.
    • Proposed as answer by ildjarn Friday, December 05, 2008 8:57 PM
    • Marked as answer by Rong-Chun Zhang Thursday, December 11, 2008 2:42 AM
    Friday, December 05, 2008 7:51 PM
    Moderator

All replies

  • Why is #include <windows.h> commented out?  The compile errors you are getting are from symbols defined in that header.
    Hans Passant.
    Friday, December 05, 2008 2:19 PM
    Moderator
  • That was me trying different orders of includes.  When I uncomment it, it tells me that windows.h is already defined.  I think the errors are coming from afxwin.h.

    I just reinstalled Visual Studio 2008 (repair/install) and it is still giving me these errors.

    I'd have a battle of the wits with you... but you are obviously unarmed.
    Friday, December 05, 2008 4:21 PM
  • Also, I just reinstalled Visual Studio 2008 (repair/install) and it is still giving me these errors.

    (Sorry about the double post, but the edit wasn't working.  I'd hit Submit for the edit, and the post was staying the same.

    I'd have a battle of the wits with you... but you are obviously unarmed.
    Friday, December 05, 2008 4:25 PM
  • Ok, check this out.  I commented out all the headers in all my files, and in my stdafx.h file I put this:

    #pragma once

    #define WIN32_LEAN_AND_MEAN        // Exclude rarely-used stuff from Windows headers

    #define _AFXDLL

    and of course it told me that System this and System that wasn't defined.

    so I added "#include <afxwin.h>"

    and it gave me those 13 errors.  My whole project has just the above few lines in stdafx.h and it gives those errors.  This is using /MD btw.



    I'd have a battle of the wits with you... but you are obviously unarmed.
    Friday, December 05, 2008 4:34 PM
  • <afxwin.h> will not #include zmouse.h.  Project + Properties, C/C++, Advanced, set Show Includes to Yes.  Rebuild and post what is written to the Output window.
    Hans Passant.
    Friday, December 05, 2008 6:30 PM
    Moderator
  • I see it says there Defaulting to 0x0600 (Windows Vista).  I am on XP right now, but why would it have worked before if that was the issue?

    By the way, this is for the project with the smaller stdafx.h file.


    1>------ Rebuild All started: Project: MITELDICEService, Configuration: Release Win32 ------
    1>Deleting intermediate and output files for project 'MITELDICEService', configuration 'Release|Win32'
    1>Compiling...
    1>stdafx.cpp
    1>Note: including file: c:\documents and settings\calvin.bell\desktop\mitel\miteldice\miteldiceservice\miteldiceservice\stdafx.h
    1>Note: including file:  C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\afxsock.h
    1>Note: including file:   C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\afxwin.h
    1>Note: including file:    C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\afx.h
    1>Note: including file:     C:\Program Files\Microsoft Visual Studio 9.0\VC\include\new.h
    1>Note: including file:      C:\Program Files\Microsoft Visual Studio 9.0\VC\include\crtdefs.h
    1>Note: including file:       C:\Program Files\Microsoft Visual Studio 9.0\VC\include\sal.h
    1>Note: including file:        c:\program files\microsoft visual studio 9.0\vc\include\codeanalysis\sourceannotations.h
    1>Note: including file:       C:\Program Files\Microsoft Visual Studio 9.0\VC\include\crtassem.h
    1>Note: including file:       C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vadefs.h
    1>Note: including file:     C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\afxver_.h
    1>Note: including file:      C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\afxv_w32.h
    1> WINVER not defined. Defaulting to 0x0600 (Windows Vista)
    1>Note: including file:       C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\zmouse.h
    1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\zmouse.h(141) : error C2146: syntax error : missing ';' before identifier 'HwndMSWheel'
    1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\zmouse.h(141) : error C2433: 'HWND' : 'inline' not permitted on data declarations
    1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\zmouse.h(141) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\zmouse.h(142) : error C2065: 'PUINT' : undeclared identifier
    1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\zmouse.h(142) : error C2146: syntax error : missing ')' before identifier 'puiMsh_MsgMouseWheel'
    1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\zmouse.h(142) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\zmouse.h(146) : error C2059: syntax error : ')'
    1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\zmouse.h(147) : error C2143: syntax error : missing ';' before '{'
    1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\zmouse.h(147) : error C2447: '{' : missing function header (old-style formal list?)
    1>Note: including file:       C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\commctrl.h
    1>Note: including file:        C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\prsht.h
    1>Note: including file:         C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\pshpack4.h
    1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\prsht.h(97) : error C2065: 'CALLBACK' : undeclared identifier
    1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\prsht.h(97) : error C2065: 'LPFNPSPCALLBACKA' : undeclared identifier
    1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\prsht.h(97) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\prsht.h(97) : fatal error C1903: unable to recover from previous error(s); stopping compilation
    Thanks for the help!
    Friday, December 05, 2008 6:45 PM
  • File + Open, C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\afxv_w32.h.  Cursor to line #169.  If you see this:

    //#include <windows.h>

    then you destroyed your SDK header files when you did an Edit + Find and Replace.  You could remove the // but there's likely more damage.  Check the file dates in the vc\atlmc\include folder to get an idea how many files are affected.  The only real way to fix this damage is to either copy them from another VS installation or by uninstalling VS, deleting the modified files by hand and reinstalling.

    Hans Passant.
    • Proposed as answer by ildjarn Friday, December 05, 2008 8:57 PM
    • Marked as answer by Rong-Chun Zhang Thursday, December 11, 2008 2:42 AM
    Friday, December 05, 2008 7:51 PM
    Moderator
  • nobugz, you rock man!  I'm not quite sure how it got changed, because I had a bad experience once with find/replace, so now I will do a find and manually change anything I need to.

    However, getting that .h file from a co-worker and replacing it solved my zmouse.h errors!

    I have no clue how you knew that, but you are amazing.  Now I only get 2 warnings, which I am sure I can work through:

    Warning    1    warning C4965: implicit box of integer 0; use nullptr or explicit cast 

    Warning    2    warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library

    Being a mostly C# guy and trying to work through all this header/linker/library stuff is really rough. 

    Thank you again!


    Thanks for the help!
    Friday, December 05, 2008 8:32 PM
  • Hi,

    I had a similar experience with upgrading an Ax Ctrl from 2005 to 2008. The includes are getting munged by VS 2008 SDK. A good way to repair is to de-install VS 2008 then re-install in the following order:

    Install VS 2008 (Base) -> Install VS 2008 SDK ->*Repair* w/ Base -> VS 2008 SP1 

    My build was be good after this sequence.

    All the best,

    Bill Shurtleff

    Thursday, December 19, 2013 8:34 PM