syntax error : missing ';' before identifier 'PVOID64' when compiling winnt.h - c++

I've recently got the source-code on a application. When im trying to build the solution, I get an error in all parts where winnt.h is included. The error codes differs a bit, but they always point to these lines in winnt.h:
typedef void *PVOID;
typedef void * POINTER_64 PVOID64;
and
struct {
DWORD crc;
BYTE rgbReserved[14];
} CRC;
So, what could be the cause of this? winnt.h is a standard header and has not been modified. Does it has something to do with me using VS 2010, or me using 64-bit windows? or is it some sort of configuration which is needed?
EDIT:
Here's the exact error-codes:
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(290): error C2146: syntax error : missing ';' before identifier 'PVOID64'
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(290): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(8992): error C2146: syntax error : missing ';' before identifier 'Buffer'
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(8992): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(8992): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(11525): error C2059: syntax error : 'constant'
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(11525): error C2238: unexpected token(s) preceding ';'
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(11556): error C2059: syntax error : 'constant'
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(11556): error C2238: unexpected token(s) preceding ';'

You need to include windows.h rather than winnt.h. When you include windows.h it will, in turn, include winnt.h. You need to do it this way for the necessary macros to be in place that are needed to compile winnt.h.
In this case, POINTER_64 is defined in BaseTsd.h like this:
#define POINTER_64 __ptr64
But if you include winnt.h before including windows.h then POINTER_64 is not defined.

If you are using DirectX SDK, try changing the VC++ Directories for include and lib to be searched last.

It looks like your configuration of the Windows SDK is invalid.
This error is caused by the fact that the compiler is unable to recognize the 'POINTER_64' statement.
You may workaround this problem by replacing 'POINTER_64' with '__ptr64'.
I had the same issue recently. Then I've reinstalled the latest version of the Windows SDK and this fixed the problem.
UPDATE
#David Heffernan, correctly points to the fact that one should include windows.h instead of winnt.h

Try to remove DirectX SDK if you have one.
Here bug is accepted:
http://connect.microsoft.com/VisualStudio/feedback/details/508204/vc10-0-errors-while-compiling-winnt-h

Corrected manually syntax in winnt.h :
typedef void * POINTER_64 PVOID64; => typedef void * POINTER_64, * PVOID64;

If you are using librdkafka, you will get this error whenever "Windows.h" included.
I fixed it by rename "librdkafka/include/basetsd.h" to a different name, or access
this library header via sub path!
I think the author of this library made this file to deal with OS platform compatibility. But with the same file name "basetsd.h" as Windows Core, it just confusing Visual Studio.

Related

Compile errors of Eigen's unsupported/CXX11/Tensor module

My project uses Eigen-3.3-beta. I can build my project in visual studio 2015 community which includes <Eigen/Core>. But after I include <unsupported\Eigen\CXX11\Tensor>, I got strange compile errors like these:
1>C:\Program Files (x86)\Windows Kits\8.1\Include\um\minwinbase.h(46): error C3646: 'nLength': unknown override specifier
1>C:\Program Files (x86)\Windows Kits\8.1\Include\um\minwinbase.h(46): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Windows Kits\8.1\Include\um\minwinbase.h(47): error C3646: 'lpSecurityDescriptor': unknown override specifier
1>C:\Program Files (x86)\Windows Kits\8.1\Include\um\minwinbase.h(47): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Windows Kits\8.1\Include\um\minwinbase.h(48): error C3646: 'bInheritHandle': unknown override specifier
......
1>C:\Program Files (x86)\Windows Kits\8.1\Include\um\minwinbase.h(295): fatal error C1003: error count exceeds 100; stopping compilation
It seems that my project works properly with Eigen-3.3-beta's normal part except unsupported module. What's more, with unsupported module included, types introduced by GLEW (e.g. GLfloat) cannot be resolved. Did I do something wrong?
It seems this stems from the include of in <unsupported\Eigen\CXX11\Tensor>.
I solved it with help from this thread (Compile error in 'winbase.h' ) and just exchanged line 38 in <unsupported\Eigen\CXX11\Tensor> from #include <winbase.h> with #include <windows.h>.
Edit: This seems to be the way it was fixed in the lasted version in the repository.

"Triangle" with VS2012?

There is a triangular mesh generator (Shewchuk, CMU), "Triangle", that are recommended by people due to its lightweight. It is written in C. However I cannot use it in my VS2012 C++ project. I am compiling it using x64 platform. I am on Windows 7 64-bit.
Basically, I compile the triangle.c as the makefile described. So, a triangle.o is generated. I then
added triangle.o as additional dependencies in my solution,
added triangle.c and triangle.h in my project .
changed triangle.c in C/C++ precompiled header option, to "not using precompiled header"
Then I got tons of errors like this:
1>C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(430): error C2143: syntax error : missing ';' before '*'
1>C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(430): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(497): error C2143: syntax error : missing ';' before '*'
1>C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(497): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(498): error C2143: syntax error : missing ';' before '*'
1>C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(498): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(2517): warning C4391: 'SHORT _InterlockedIncrement16(volatile SHORT *)' : incorrect return type for intrinsic function, expected 'short'
I am just wondering, is there anyway to make the triangular mesh generator work with VS2012 C++ project? If so, what is the right way to set it up on VS2012 C++ x64?
You might want to have a look at this: Compilation errors of a simple C++ project in VS 2012.RC 4
disable pre-compiled headers, and delete the pch file from the intermediate directory.
This initially didn't work for me, so I tried moving #include at the top of the file, before all other includes, and this worked for me.

Include winnt.h in my project

I am doing a small personal project involving printing out info about a PE file.
I have read that most of the pe structure is already defined in winnt.h header.
Upon including the winnt.h, and compiling the project i get the following error:
#error : "No Target Architecture"
I tried putting a define x86, it might have fixed the architecture problem, but there are even more compilation problems.
For example:
1>c:\program files (x86)\windows kits\8.0\include\um\winnt.h(363): error C2146: syntax error : missing ';' before identifier 'WCHAR'
1>c:\program files (x86)\windows kits\8.0\include\um\winnt.h(363): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\8.0\include\um\winnt.h(367): error C2143: syntax error : missing ';' before '*'
1>c:\program files (x86)\windows kits\8.0\include\um\winnt.h(367): error C2040: 'PWSTR' : 'CONST' differs in levels of indirection from 'WCHAR *'
check Compiler->Enable Microsoft extensions in Project options or use -Ze flag if you're compiling from the command line.

openGl - 143 errors from the includes

I'm working on windows XP with Visual C++ 2008 Express Eition.
Im trying to include:
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
and getting alot of errors like:
1>c:\program files\microsoft sdks\windows\v6.0a\include\gl\gl.h(1152) : error C2144: syntax error : 'void' should be preceded by ';'
1>c:\program files\microsoft sdks\windows\v6.0a\include\gl\gl.h(1152) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v6.0a\include\gl\gl.h(1152) : error C2146: syntax error : missing ';' before identifier 'glAccum'
1>c:\program files\microsoft sdks\windows\v6.0a\include\gl\gl.h(1152) : error C2182: 'APIENTRY' : illegal use of type 'void'
etc.
My question is: can i use those includes or do i need to get those libraries from somewhere at first?
Thanks.
For reasons known to Microsoft only, the OpenGL headers provided with the various Windows SDKs require that you
#include <windows.h>
before.
You are probably trying to compile it as C++ instead of C, or something along those lines.
Why are you using SDKs named 'v6.0a' with VC++2K8? Are you sure that's the latest OpenGL headers you have? You should be using latest Platform SDK and OpenGL headers whenever possible.

Error building legacy code with VS 2005

Trying to build a legacy code in VS2005 and get errors in VC header files.
d:\Compilers\Microsoft Visual Studio 8\VC\include\xutility(2096) : error C2065: '_Sb' : undeclared identifier
d:\Compilers\Microsoft Visual Studio 8\VC\include\xutility(2176) : see reference to class template instantiation 'std::istreambuf_iterator<_Elem,_Traits>' being compiled
d:\Compilers\Microsoft Visual Studio 8\VC\include\xutility(2096) : error C3861: '_Strbuf': identifier not found
d:\Compilers\Microsoft Visual Studio 8\VC\include\xutility(2096) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
d:\Compilers\Microsoft Visual Studio 8\VC\include\xutility(2096) : error C2061: syntax error : identifier '_Sb'
d:\Compilers\Microsoft Visual Studio 8\VC\include\xutility(2097) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
d:\Compilers\Microsoft Visual Studio 8\VC\include\xutility(2098) : error C2143: syntax error : missing ';' before '{'
d:\Compilers\Microsoft Visual Studio 8\VC\include\xutility(2098) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
d:\Compilers\Microsoft Visual Studio 8\VC\include\xutility(2176) : fatal error C1075: end of file found before the left brace '{' at 'd:\Compilers\Microsoft Visual Studio 8\VC\include\xutility(15)' was matched
I find the legacy code uses a vector and if I comment out those variables then the code compiles without any errors.
I get these errors even if I just include vector header without defining any variable.
All the files in the project are cpp files.
Do I need to add some preprocessor directives or compiler settings to get this working?
You may find that running the pre-process phase on one of the files might show if any macros are being expanded that conflict with vector or _Strbuf. See my post on how to do this:
Compiling a project (VS 2008) with the /p argument (preprocess to a file) doesn't compile
You probably need to remove some conflicting predefined macros. Leading underscores followed by uppercase letters, as in _Sb are reserved for the implementation. If you have that defined as something else, you'll get such errors. It's also possible the errors are because you've defined _Strbuf ot _Got.