winnt.h(222): Error C2146 ...

All,

line 222 in winnt.h reads like this:

     typedef
void * POINTER_64 PVOID64;

and creates the error message

     Error C2146: syntax error: missing ';' before identifier PVOID64.

I am trying to throw VC++ 2005 Express on Windows 2000 Pro SP4 at a modifed version of the amcap sample program of DirectShow.  This is the version I have downloaded with DirectX 9.0b on 11 Oct. 2004 and have successfully used with VC++ 6 SP5 on the same program.  (The DXSDK involved is (one of) the last issue of DirectX that included DirectShow.)

I have the platform SDK downloaded, and putting its include directory before or after the baseclasses and DXSDK include directories does not change anything.

To me, the line in question looks wrong at first sight, and I agree with the compiler that PVOID64 is an extraneous element there.  However, I am not sure if by some "hidden" #define the POINTER_64 takes on a meaning that would make "void * POINTER_64" a legitimate multi-worded data type.  I have not installed any 64-bit pieces because at this time, 64-bit computing is irrelevant for me.

There are a few other messages, which may or may not help in diagnosing the one at hand.  First is one about line 278 "operator=(LONG);" in baseclasses\ctlutil.h missing a type specifier, and the second one is about "atlbase.h" missing (I suspect another piece of download needed, or I have kept the installation of the platform SDK too tight).

I have previously recompiled and modified another, simpler program that uses only the platform SDK but not any Direct-whatnot stuff under VC++ 2005 Express successfully.

Question:

Is the compiler correct in annotating a bug in winnt.h, i.e., the Platform SDK, or did I miss or mess up something in carrying my amcap derivate over from VC++ 6

I appreciate any and all comments and suggestions.

Cheers,         Jochen



Answer this question

winnt.h(222): Error C2146 ...

  • renemt

    Hi Hans-Jochen,

    seems to me that ctlutil.h is missing an include so that LONG is not defined at that point.
    Make sure to include winnt.h or windows.h before using LONG in ctlutil.h.

    HTH,
    SvenC

  • Lam Chan

    I may have a solution that doesn't involve modifying the base files. In "Tools -> Options -> Projects and Solutions -> VC++ Directories -> Include Files" make sure the default include folders are first, and put any extra include folders you want here.

    In the project properties under "C/C++ -> General" make sure the "Additional Include Directories" is empty. Any additional include directories should be in the folder above.

    This solved all my problems. Hope it solves yours!


  • Minherz

    Okay, okay, I goofed - on three counts.

    >>I am trying to throw VC++ 2005 Express on Windows 2000 Pro SP4 at a modifed version of the amcap sample program of DirectShow.  This is the version I have downloaded with DirectX 9.0b on 11 Oct. 2004 ...<<

    The Platform SDK contains DirectShow and I have kept it during installation, so I suppose that is what I am using.

    >>I have the platform SDK downloaded, and putting its include directory before or after the baseclasses and DXSDK include directories does not change anything.<<

    Wrong.  Putting the Platform SDK include directory first gets rid of the C2146 error.  Interesting is that the mouse-over display says "typedef void *POINTER_64" when I am over POINTER_64 and "typedef void *PVOID64" when I am over PVOID64 ...

    The third goof is missing the Platform SDK's subdirectory "Include\atl".  (VC++ 6 either has the corresponding ATL\Include directory apparently automatically used.)

    That leaves me with just one error to figure out,

       line 278 "operator=(LONG);" in baseclasses\ctlutil.h missing a type specifier (error C4430)

    I have made sure that the baseclasses of the directShow piece in the Platform SDK is used.

    I apoogize for the premature alarms.

    Cheers,             Jochen


  • kathyw

    Jonathan,

    thanks for your advice.  Yes, it makes the compilation error C4430 in ctlutil.h go away.  This is 100% Microsoft's code, not mine, so I will post a bug report.  Your heroic efforts at implementing faithfully the C++ standard have struck here - VC++ 6 SP5 does not complain about this code (taken from DXSDK 9.0b where this passage is identical).

    Cheers,             Jochen

  • Hawk390

    Thanks a lot everyone. This discussion helped me alot to get started with VS2005 and directshow.

    Thanks,
    krishna.

  • Ivan Ivanyuk

    I have an orrorific solution for problem C2146.

    I found into file baseTsd.h the definition for POINTER_64 which is this,

    at line 22 more less:


    #ifndef _BASETSD_H_

    #define _BASETSD_H_

    #if !defined(_MAC) && (defined(_M_MRX000) || defined(_M_AMD64) || defined(_M_IA64)) && (_MSC_VER >= 1100) && !(defined(MIDL_PASS) || defined(RC_INVOKED))

    #define POINTER_64 __ptr64  // <-- This code is not called for some reason.

    typedef unsigned __int64



    I simply put this definition over the POINTER_64 typedef like this:

    #define POINTER_64 __ptr64  // <<---- ORROR !!!

    typedef void *PVOID;

    typedef void * POINTER_64 PVOID64;

    And I was able to compile my Torque Game Engine SDK with absolutelly no functionality problems.


  • gli268

    I have a similar error

    1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winnt.h(222) : error C2146: syntax error : missing ';' before identifier 'PVOID64'

    1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winnt.h(222) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

    1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winnt.h(5940) : error C2146: syntax error : missing ';' before identifier 'Buffer'

    1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winnt.h(5940) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

    1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winnt.h(5940) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

    ...which are all in winnt.h, which is included from windows.h (as far as I can tell - is there a problem with the "show Includes" option). Is there an updated set of h files I need to download

    Cheers
    John


  • Vivek Dalvi-MSFT

    I am experiencing this issue as well...is there an "official" solution

  • Brent Williams

    I had a similar error. One which I just fixed, but thought I should post the solution.  In case someone else runs accross this same issue, I could potentially save you some work.

    Basically what happened was that I thought that the issue was with the Visual Studio Include files order (see Tools->Options->Projects and Solutions->VC++ Directories->Show directories for: Include files). Only a while later did I realize that the problem was that the project itself had some include files (see project Properties->Configuration Properties->C/C++->General) that takes precedence over the Visual Studio Include files.  I also included the directshow header files in the VS Include files, but this time, since they were explicitly listed there, I could choose which order I wanted them in, i.e. that the Platform SDK had higher priority than the DirectX directories.

    Other than that I had to patch a few bugs with the BaseClasses source files. One was the "operator=(LONG);" issue already discussed elsewhere in this thread.  In a few places there were "int"s declared in for loops that had to be declared outside the for loops.

     - Waldemar



  • drrubberchub

    This does indeed look like the same issue. I would first use the /showIncludes compiler option to ensure that you have a consistent set of include files. If that doesn't show up any problems then I would ensure that the version of the Platform SDK that you are using matches the version of Visual C++ 2005 that you have installed.

  • G. Andrew Duthie

    There are several bugs in the BaseClasses when you compile it with vs2005, but they are easy to fix. There are two for scoping errors, the static variable definition error and that one for the operator= which was pointed out. Thats what I can remember.
    But one thing for you to try. When I was compiling an application the other day, it was complaining that something was undefined, but it should have been. I managed to trace this back to _WIN32_WINNT not being defined. So double check that you do have this defined. Also, make sure that any other preprocessor directives that you need are also defined.

  • Koukai Chou

    Hi,
        I fixed the problems mentioned above. The only problem now is the compiler can't find <fstream.h>. I tried just including <fstream> but it didn't recognise the functions (this also happens in VC++ 6.0).
         Any ideas would be helpful.

    All the best.

  • bitbonk

    No: the problem here is that this member operator function does not have a return type:

        operator=(LONG);

    By looking at the code it seems that it should be:

        COARefTime& operator=(LONG);


  • Whololo

    ah, fixed the problem.. if i include <fstream> I have to declare std namespace before using the code. Thanks for the help with the original compiling problems.

    Cya!

  • winnt.h(222): Error C2146 ...