Error in windows file mfreadwrite.h - c++

I have a project where I have to use the functions of "mfreadwrite.h", but when I try to compile my project I get these errors:
5>C:\Program Files (x86)\Windows Kits\8.1\Include\um\mfreadwrite.h(260): error C2065: 'IMFMediaSource': undeclared identifier
5>C:\Program Files (x86)\Windows Kits\8.1\Include\um\mfreadwrite.h(260): error C2065: 'pMediaSource': undeclared identifier
5>C:\Program Files (x86)\Windows Kits\8.1\Include\um\mfreadwrite.h(261): error C2065: 'pAttributes': undeclared identifier
5>C:\Program Files (x86)\Windows Kits\8.1\Include\um\mfreadwrite.h(261): error C2275: 'IMFAttributes': illegal use of this type as an expression
5> c:\program files (x86)\windows kits\8.1\include\um\mfobjects.h(310): note: see declaration of 'IMFAttributes'
5>C:\Program Files (x86)\Windows Kits\8.1\Include\um\mfreadwrite.h(262): error C2065: 'ppSourceReader': undeclared identifier
5>C:\Program Files (x86)\Windows Kits\8.1\Include\um\mfreadwrite.h(262): error C2275: 'IMFSourceReader': illegal use of this type as an expression
5> C:\Program Files (x86)\Windows Kits\8.1\Include\um\mfreadwrite.h(52): note: see declaration of 'IMFSourceReader'
5>C:\Program Files (x86)\Windows Kits\8.1\Include\um\mfreadwrite.h(262): warning C4229: anachronism used: modifiers on data are ignored
5>C:\Program Files (x86)\Windows Kits\8.1\Include\um\mfreadwrite.h(1000): error C2065: 'IMFMediaSink': undeclared identifier
5>C:\Program Files (x86)\Windows Kits\8.1\Include\um\mfreadwrite.h(1000): error C2065: 'pMediaSink': undeclared identifier
5>C:\Program Files (x86)\Windows Kits\8.1\Include\um\mfreadwrite.h(1001): error C2065: 'pAttributes': undeclared identifier
5>C:\Program Files (x86)\Windows Kits\8.1\Include\um\mfreadwrite.h(1001): error C2275: 'IMFAttributes': illegal use of this type as an expression
5> c:\program files (x86)\windows kits\8.1\include\um\mfobjects.h(310): note: see declaration of 'IMFAttributes'
5>C:\Program Files (x86)\Windows Kits\8.1\Include\um\mfreadwrite.h(1002): error C2065: 'ppSinkWriter': undeclared identifier
5>C:\Program Files (x86)\Windows Kits\8.1\Include\um\mfreadwrite.h(1002): error C2275: 'IMFSinkWriter': illegal use of this type as an expression
5> C:\Program Files (x86)\Windows Kits\8.1\Include\um\mfreadwrite.h(73): note: see declaration of 'IMFSinkWriter'
can anyone help me please?
ps:
I tried cleaning and rebuilding my project a couple of times but I still get the errors.

I had a similar problem recently and the solution for me was including mfidl.h before every mfreadwrite.h include directives.
It can be tricky, because the compiler output might be misleading when the file causing the problem is included into another file.
The easiest way I found to track the problem back to the source was showing the included files in the compile output window. (Project / Properties / Configuration Properties / C/C++ / Advanced / Show Includes <- set it to Yes)
I started going back from the first error message and checked the custom headers and source files (the ones I wrote).
Environment: Windows 8.1/64b, Visual Studio 2015 Express for Windows Desktop.

I had a case where I was trying to get a project to compile in Visual Studio 2010 that used the IMFSinkWriter. It compiled fine with Visual Studio 2013, but for 2010 I had to place the following in the stdafx.h file:
#define WINVER 0x0601
#define _WIN32_WINNT 0X0601

Related

ATL complains about not including Windows after VS2012 -> VS2017

I'm currently update our projects from VS2012 to VS2017. This has led one project to crash and moan in compilation about ATL.
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(450): error C2143: syntax error: missing ')' before '__stdcall'
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(450): error C2143: syntax error: missing ';' before '__stdcall'
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(450): error C2059: syntax error: '__stdcall'
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(450): error C2059: syntax error: ')'
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(451): error C2065: 'PFNMOVEFILETRANSACTED': undeclared identifier
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(451): error C2146: syntax error: missing ';' before identifier 'pfMoveFileTransacted'
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(451): error C2065: 'pfMoveFileTransacted': undeclared identifier
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(451): error C2146: syntax error: missing ';' before identifier 'GetProcAddress'
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(453): error C2065: 'pfMoveFileTransacted': undeclared identifier
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(455): error C2065: 'pfMoveFileTransacted': undeclared identifier
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(571): error C2143: syntax error: missing ')' before '__stdcall'
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(571): error C2143: syntax error: missing ';' before '__stdcall'
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(571): error C2059: syntax error: '__stdcall'
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(571): error C2059: syntax error: ')'
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(572): error C2065: 'PFNFINDFIRSTFILETRANSACTED': undeclared identifier
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(572): error C2146: syntax error: missing ';' before identifier 'pfFindFirstFileTransacted'
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(572): error C2065: 'pfFindFirstFileTransacted': undeclared identifier
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(572): error C2146: syntax error: missing ';' before identifier 'GetProcAddress'
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(574): error C2065: 'pfFindFirstFileTransacted': undeclared identifier
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(576): error C2065: 'pfFindFirstFileTransacted': undeclared identifier
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(576): error C2065: 'FindExInfoStandard': undeclared identifier
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atltransactionmanager.h(576): error C2065: 'FindExSearchNameMatch': undeclared identifier
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\atlmfc\include\atlcom.h(175): error C2065: 'COINIT_MULTITHREADED': undeclared identifier
1>Done building project "MyProj.vcxproj" -- FAILED.
With error lines such as "undeclared identifier" refers to headers in the windows.h library.
When I include I include through a StdAfx.h which has;
#include <atlbase.h>
#include <atlcom.h>
Regardless where I put Windows.h, the error occurs. I find it likely that it is generated by _WIN32_WINNTstuff but all of that "should" work. Is it deprecated? I don't know... Anyone have any ideas?
In my case there were multiple project including each others stdafx.h headers. This caused the macros to fail/corrupt. Sorting that out and using correct values of WINVER and _WIN32_WINNT fixed it all.
Aside from Alexander's answer make sure that you do NOT define the following:
#define NOTEXTMETRIC

Migrating MFC app from Visual Studio 2012 to Visual Studio 2013

I'm trying to migrate a MFC project over from Visual Studio 2012 (where it's compiling fine) to Visual Studio 2013 and I'm getting a heap of undefined errors as per below.
These are all caused when pulling in the precompiled header - and I can only assume I'm including some of the MFC header files in the wrong order - anyone know what order they should be now?
The errors indicate that PGESTURECONFIG is defined in WinUser.h - but it doesn't like me including that anywhere before afxwin.h (it produces different errors if I do indicating "No Target Architecture")
This is what I believe is the relevant section is in the precompiled header currently:
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxcmn.h> // MFC support for Windows 95 Common Controls
#include <afxcview.h> // MFC CTreeView, etc...
And this is the kind of errors I'm getting:
3>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\afxwin.h(2092): error C2146: syntax error : missing ';' before identifier 'm_pConfigs'
3>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\afxwin.h(2092): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
3>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\afxwin.h(2019): error C2065: 'GID_ZOOM' : undeclared identifier
3>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\afxwin.h(2019): error C2065: 'GC_ZOOM' : undeclared identifier
3>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\afxwin.h(2025): error C2065: 'GID_ROTATE' : undeclared identifier
3>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\afxwin.h(2025): error C2065: 'GC_ROTATE' : undeclared identifier
3>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\afxwin.h(2031): error C2065: 'GID_TWOFINGERTAP' : undeclared identifier
3>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\afxwin.h(2031): error C2065: 'GC_TWOFINGERTAP' : undeclared identifier
3>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\afxwin.h(2045): error C2065: 'GID_PAN' : undeclared identifier
3>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\afxwin.h(2045): error C2065: 'GC_PAN' : undeclared identifier
3>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\afxwin.h(2051): error C2065: 'GID_PAN' : undeclared identifier
3>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\afxwin.h(2051): error C2065: 'GC_PAN_WITH_SINGLE_FINGER_VERTICALLY' : undeclared identifier
3>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\afxwin.h(2057): error C2065: 'GID_PAN' : undeclared identifier
3>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\afxwin.h(2057): error C2065: 'GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY' : undeclared identifier
3>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\afxwin.h(2063): error C2065: 'GID_PAN' : undeclared identifier
3>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\afxwin.h(2063): error C2065: 'GC_PAN_WITH_GUTTER' : undeclared identifier
3>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\afxwin.h(2069): error C2065: 'GID_PAN' : undeclared identifier
3>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\afxwin.h(2069): error C2065: 'GC_PAN_WITH_INERTIA' : undeclared identifier
3>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\afxwin.h(2953): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
3>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\afxwin.h(2953): error C2146: syntax error : missing ';' before identifier 'GetCurrentGestureInfo'
3>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\afxwin.h(2954): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
3>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\afxwin.h(2956): warning C4183: 'GetCurrentGestureInfo': missing return type; assumed to be a member function returning 'int'
3>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\afxwin.h(2986): error C2061: syntax error : identifier 'PTOUCHINPUT'
3>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\afxwin.h(2996): error C2061: syntax error : identifier 'PTOUCHINPUT'
3>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\afxwin.h(3009): error C2146: syntax error : missing ';' before identifier 'm_pCurrentGestureInfo'
3>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\afxwin.h(3009): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
3>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\afxwin.h(2955): error C2065: 'm_pCurrentGestureInfo' : undeclared identifier
Any advice appreciated.
I had exactly the same problem today after converting a Visual Studio 2010 project to Visual Studio 2013.
In my case, it turned out to be "hard coded" WINVER define injected via the project's C++ configuration properties (preprocessor definition section), where WINVER=0x500 was defined ages ago.
I solved it by setting Properties -> C/C++ Preprocessor Definitions to
NTDDI_VERSION= 0x06030000;WINVER=0x0A00;_WIN32_WINNT=0x0A00;%(PreprocessorDefinitions)
I have added these settings into stdafx.h file and it worked for me:
WINVER=0x601;
_WIN32_WINNT=0x601;
_WIN32_WINDOWS=0x601;
_WIN32_IE=0x601;

Get massive compile error whenever windows.h is included, my environment is visual studio 2013 in win 7

I have a CPP file Log.cpp which has one line code:
#include "windows.h"
When I compile it, massive syntax errors display:
1>------ Build started: Project: topx, Configuration: Debug Win32 ------
1> Log.cpp
1>c:\program files (x86)\windows kits\8.1\include\um\winbase.h(936): error C2065: 'hMem' : undeclared identifier
1>c:\program files (x86)\windows kits\8.1\include\um\winbase.h(936): error C2065: 'dwBytes' : undeclared identifier
1>c:\program files (x86)\windows kits\8.1\include\um\winbase.h(938): 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\winbase.h(938): error C2491: '_Ret_reallocated_bytes_' : definition of dllimport data not allowed
1>c:\program files (x86)\windows kits\8.1\include\um\winbase.h(938): error C2078: too many initializers
1>c:\program files (x86)\windows kits\8.1\include\um\winbase.h(938): error C2146: syntax error : missing ';' before identifier 'HGLOBAL'
1>c:\program files (x86)\windows kits\8.1\include\um\winbase.h(938): error C2143: syntax error : missing ';' before '__stdcall'
1>c:\program files (x86)\windows kits\8.1\include\um\winbase.h(938): error C2377: 'HGLOBAL' : redefinition; typedef cannot be overloaded with any other symbol
1> c:\program files (x86)\windows kits\8.0\include\shared\minwindef.h(211) : see declaration of 'HGLOBAL'
1>c:\program files (x86)\windows kits\8.1\include\um\winbase.h(940): error C2146: syntax error : missing ')' before identifier 'hMem'
1>c:\program files (x86)\windows kits\8.1\include\um\winbase.h(940): warning C4229: anachronism used : modifiers on data are ignored
1>c:\program files (x86)\windows kits\8.1\include\um\winbase.h(940): 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\winbase.h(943): error C2059: syntax error : ')'
....
....
But all is OK when I compile it under windows 8, what is the problem?
Change from:
C:\Program Files (x86)\Windows Kits\8.0\Include\shared
to
C:\Program Files (x86)\Windows Kits\8.1\Include\shared
in "Additional include directories" of project resolve this problem, but I do not know why.

#include <windows.h> causes a lot of syntax errors

My program uses Qt and OpenGL. It compiles correctly under Linux and Mac.
When compiled on windows, I need to #include windows.h in order to use OpenGL, the code is like following,
#if defined(_WIN32) || defined(_WIN64) || defined(WIN32) || defined(WIN64)
#include <windows.h>
#endif
#ifdef __APPLE__
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
#else
#include <GL/glu.h>
#include <GL/glut.h>
#endif
However, there are a lot of error messages like
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(167) : error C2146: syntax error : missing ')' before identifier 'PRPC_MESSAGE'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(167) : error C2165: 'left-side modifier' : cannot modify pointers to data
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(167) : error C2513: 'void *' : no variable declared before '='
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(167) : error C2440: 'initializing' : cannot convert from 'std::ostream' to 'void *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(168) : error C2059: syntax error : ')'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(226) : error C2146: syntax error : missing ')' before identifier 'RPC_MESSAGE'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(226) : warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(226) : error C2491: 'I_RpcNegotiateTransferSyntax' : definition of dllimport data not allowed
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(227) : error C2059: syntax error : ')'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(235) : error C2146: syntax error : missing ')' before identifier 'RPC_MESSAGE'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(235) : warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(235) : error C2491: 'I_RpcGetBuffer' : definition of dllimport data not allowed
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(236) : error C2059: syntax error : ')'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(242) : error C2146: syntax error : missing ')' before identifier 'RPC_MESSAGE'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(242) : warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(242) : error C2491: 'I_RpcGetBufferWithObject' : definition of dllimport data not allowed
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(244) : error C2059: syntax error : ')'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(251) : error C2146: syntax error : missing ')' before identifier 'RPC_MESSAGE'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(251) : warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(251) : error C2491: 'I_RpcSendReceive' : definition of dllimport data not allowed
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(252) : error C2059: syntax error : ')'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(259) : error C2146: syntax error : missing ')' before identifier 'RPC_MESSAGE'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(259) : warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(259) : error C2491: 'I_RpcFreeBuffer' : definition of dllimport data not allowed
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(260) : error C2059: syntax error : ')'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(267) : error C2146: syntax error : missing ')' before identifier 'PRPC_MESSAGE'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(267) : warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(267) : error C2491: 'I_RpcSend' : definition of dllimport data not allowed
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(268) : error C2059: syntax error : ')'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(275) : error C2146: syntax error : missing ')' before identifier 'PRPC_MESSAGE'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(275) : warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(275) : error C2491: 'I_RpcReceive' : definition of dllimport data not allowed
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(277) : error C2059: syntax error : ')'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(284) : error C2146: syntax error : missing ')' before identifier 'RPC_MESSAGE'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(284) : warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(284) : error C2491: 'I_RpcFreePipeBuffer' : definition of dllimport data not allowed
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(285) : error C2059: syntax error : ')'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(302) : error C2146: syntax error : missing ')' before identifier 'I_RPC_MUTEX'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(302) : warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(302) : error C2182: 'I_RpcRequestMutex' : illegal use of type 'void'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(302) : error C2491: 'I_RpcRequestMutex' : definition of dllimport data not allowed
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(303) : error C2059: syntax error : ')'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(438) : error C2061: syntax error : identifier 'cout'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(453) : error C2061: syntax error : identifier 'cout'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(479) : error C2061: syntax error : identifier 'cout'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(487) : error C2061: syntax error : identifier 'cout'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(534) : error C2061: syntax error : identifier 'cout'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(542) : error C2061: syntax error : identifier 'cout'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(728) : error C2061: syntax error : identifier 'cout'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(744) : error C2061: syntax error : identifier 'cout'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(754) : error C2146: syntax error : missing ')' before identifier 'UUID'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(754) : warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(754) : error C2491: 'I_UuidCreate' : definition of dllimport data not allowed
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(755) : error C2059: syntax error : ')'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(763) : error C2061: syntax error : identifier 'cout'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(771) : error C2061: syntax error : identifier 'cout'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(779) : error C2061: syntax error : identifier 'cout'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(838) : error C2061: syntax error : identifier 'cout'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(848) : error C2061: syntax error : identifier 'cout'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(873) : error C2144: syntax error : 'unsigned long' should be preceded by ')'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(873) : error C2448: 'I_RpcConnectionInqSockBuffSize' : function-style initializer appears to be a function definition
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(874) : error C2144: syntax error : 'unsigned long' should be preceded by ';'
C:\Program Files (x86)\Windows Kits\8.1\include\shared\rpcdcep.h(874) : fatal error C1903: unable to recover from previous error(s); stopping compilation
If I don't #include windows.h, then those errors will not appear.
I am using VS2013 with Qt 5.3.
OpenGL on Microsoft Windows is tied to WGL, which is in turn tied to GDI.
As a result, you cannot #include <gl/gl.h> (you are indirectly doing this by including <GL/glu.h>) without first including some Windows-specific header that defines GDI/Windows pre-processor tokens such as WINGDIAPI and APIENTRY. But that is actually the extent to which any OpenGL program on Windows is tied to anything Windows-specific (header wise).
WinDef.h defines APIENTRY and WinGDI.h defines WINGDIAPI - including Windows.h brings in both of those headers (and a lot of other garbage unfortunately). So including Windows.h is mostly a convenience; to minimally compile OpenGL software on Windows you should #include <WinDef.h> followed by #include <WinGDI.h> and then finally #include <GL/gl.h>.
Alternatively, you can #define WIN32_LEAN_AND_MEAN just prior to #include <Windows.h> and it will significantly reduce the number of unrelated things that are brought in by including that header. Many Visual C++ projects actually define that pre-processor definition by default when they are first created, you might want to see if your project is configured that way.
windows.h clutter the global namespace with tons of bad things like ERROR, Rectangle ...
One way around the problem is to declare needed functions your self (I guess this is not too mutch work since you will not need more than 10 functions or so). You can call the include file wgl.h or something.
__declspec(dllimport) void* __stdcall wglCreateContext(void* hdc);
//... Other functions you need
The OpenGL API is defined outside windows.h so no problem there

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.