Solved

Compilation errors with including <windows.h> in a windows driver application.

Posted on 2014-04-24
6
166 Views
Last Modified: 2016-06-02
I need to include the file <windows.h> in a windows driver application built using DDK winddk\6001.18001. But this includes file <winbase.h> and during compilation I get hundreds of errors, which I must resolve:

c:\winddk\6001.18001\inc\api\winbase.h(316) : error C2061: syntax error : identi
fier 'CRITICAL_SECTION'
c:\winddk\6001.18001\inc\api\winbase.h(316) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(317) : error C2061: syntax error : identi
fier 'PCRITICAL_SECTION'
c:\winddk\6001.18001\inc\api\winbase.h(317) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(318) : error C2061: syntax error : identi
fier 'LPCRITICAL_SECTION'
c:\winddk\6001.18001\inc\api\winbase.h(318) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(320) : error C2061: syntax error : identi
fier 'CRITICAL_SECTION_DEBUG'
c:\winddk\6001.18001\inc\api\winbase.h(320) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(321) : error C2061: syntax error : identi
fier 'PCRITICAL_SECTION_DEBUG'
c:\winddk\6001.18001\inc\api\winbase.h(321) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(322) : error C2061: syntax error : identi
fier 'LPCRITICAL_SECTION_DEBUG'
c:\winddk\6001.18001\inc\api\winbase.h(322) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(401) : error C2061: syntax error : identi
fier 'SRWLOCK'
c:\winddk\6001.18001\inc\api\winbase.h(401) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(401) : error C2059: syntax error : ','
c:\winddk\6001.18001\inc\api\winbase.h(409) : error C2146: syntax error : missin
g ')' before identifier 'SRWLock'
c:\winddk\6001.18001\inc\api\winbase.h(409) : error C2061: syntax error : identi
fier 'SRWLock'
c:\winddk\6001.18001\inc\api\winbase.h(409) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(410) : error C2059: syntax error : ')'
c:\winddk\6001.18001\inc\api\winbase.h(416) : error C2146: syntax error : missin
g ')' before identifier 'SRWLock'
c:\winddk\6001.18001\inc\api\winbase.h(416) : error C2061: syntax error : identi
fier 'SRWLock'
c:\winddk\6001.18001\inc\api\winbase.h(416) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(417) : error C2059: syntax error : ')'
c:\winddk\6001.18001\inc\api\winbase.h(423) : error C2146: syntax error : missin
g ')' before identifier 'SRWLock'
c:\winddk\6001.18001\inc\api\winbase.h(423) : error C2061: syntax error : identi
fier 'SRWLock'
c:\winddk\6001.18001\inc\api\winbase.h(423) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(424) : error C2059: syntax error : ')'
c:\winddk\6001.18001\inc\api\winbase.h(430) : error C2146: syntax error : missin
g ')' before identifier 'SRWLock'
c:\winddk\6001.18001\inc\api\winbase.h(430) : error C2061: syntax error : identi
fier 'SRWLock'
c:\winddk\6001.18001\inc\api\winbase.h(430) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(431) : error C2059: syntax error : ')'
c:\winddk\6001.18001\inc\api\winbase.h(437) : error C2146: syntax error : missin
g ')' before identifier 'SRWLock'
c:\winddk\6001.18001\inc\api\winbase.h(437) : error C2061: syntax error : identi
fier 'SRWLock'
c:\winddk\6001.18001\inc\api\winbase.h(437) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(438) : error C2059: syntax error : ')'
c:\winddk\6001.18001\inc\api\winbase.h(444) : error C2061: syntax error : identi
fier 'CONDITION_VARIABLE'
c:\winddk\6001.18001\inc\api\winbase.h(444) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(444) : error C2059: syntax error : ','
c:\winddk\6001.18001\inc\api\winbase.h(450) : error C2146: syntax error : missin
g ')' before identifier 'ConditionVariable'
c:\winddk\6001.18001\inc\api\winbase.h(450) : error C2061: syntax error : identi
fier 'ConditionVariable'
c:\winddk\6001.18001\inc\api\winbase.h(450) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(451) : error C2059: syntax error : ')'
c:\winddk\6001.18001\inc\api\winbase.h(457) : error C2146: syntax error : missin
g ')' before identifier 'ConditionVariable'
c:\winddk\6001.18001\inc\api\winbase.h(457) : error C2061: syntax error : identi
fier 'ConditionVariable'
c:\winddk\6001.18001\inc\api\winbase.h(457) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(458) : error C2059: syntax error : ')'
c:\winddk\6001.18001\inc\api\winbase.h(464) : error C2146: syntax error : missin
g ')' before identifier 'ConditionVariable'
c:\winddk\6001.18001\inc\api\winbase.h(464) : error C2061: syntax error : identi
fier 'ConditionVariable'
c:\winddk\6001.18001\inc\api\winbase.h(464) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(465) : error C2059: syntax error : ')'
c:\winddk\6001.18001\inc\api\winbase.h(471) : error C2146: syntax error : missin
g ')' before identifier 'ConditionVariable'
c:\winddk\6001.18001\inc\api\winbase.h(471) : error C2061: syntax error : identi
fier 'ConditionVariable'
c:\winddk\6001.18001\inc\api\winbase.h(471) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(471) : error C2059: syntax error : ','
c:\winddk\6001.18001\inc\api\winbase.h(474) : error C2059: syntax error : ')'
c:\winddk\6001.18001\inc\api\winbase.h(480) : error C2146: syntax error : missin
g ')' before identifier 'ConditionVariable'
c:\winddk\6001.18001\inc\api\winbase.h(480) : error C2061: syntax error : identi
fier 'ConditionVariable'
c:\winddk\6001.18001\inc\api\winbase.h(480) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(480) : error C2059: syntax error : ','
c:\winddk\6001.18001\inc\api\winbase.h(484) : error C2059: syntax error : ')'
c:\winddk\6001.18001\inc\api\winbase.h(531) : error C2061: syntax error : identi
fier 'LPLDT_ENTRY'
c:\winddk\6001.18001\inc\api\winbase.h(531) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(2279) : warning C4005: 'InterlockedExchan
gePointer' : macro redefinition
        c:\winddk\6001.18001\inc\ddk\wdm.h(11164) : see previous definition of '
InterlockedExchangePointer'
c:\winddk\6001.18001\inc\api\winbase.h(2292) : error C2059: syntax error : '('
c:\winddk\6001.18001\inc\api\winbase.h(2321) : error C2084: function 'LONGLONG _
InterlockedAnd64(volatile LONGLONG *,LONGLONG)' already has a body
        c:\winddk\6001.18001\inc\ddk\ntddk.h(4449) : see previous definition of
'_InterlockedAnd64'
c:\winddk\6001.18001\inc\api\winbase.h(2339) : error C2084: function 'LONGLONG _
InterlockedOr64(volatile LONGLONG *,LONGLONG)' already has a body
        c:\winddk\6001.18001\inc\ddk\ntddk.h(4469) : see previous definition of
'_InterlockedOr64'
c:\winddk\6001.18001\inc\api\winbase.h(2357) : error C2084: function 'LONGLONG _
InterlockedXor64(volatile LONGLONG *,LONGLONG)' already has a body
        c:\winddk\6001.18001\inc\ddk\ntddk.h(4489) : see previous definition of
'_InterlockedXor64'
c:\winddk\6001.18001\inc\api\winbase.h(2374) : error C2084: function 'LONGLONG _
InterlockedIncrement64(volatile LONGLONG *)' already has a body
        c:\winddk\6001.18001\inc\ddk\ntddk.h(4509) : see previous definition of
'_InterlockedIncrement64'
c:\winddk\6001.18001\inc\api\winbase.h(2391) : error C2084: function 'LONGLONG _
InterlockedDecrement64(volatile LONGLONG *)' already has a body
        c:\winddk\6001.18001\inc\ddk\ntddk.h(4528) : see previous definition of
'_InterlockedDecrement64'
c:\winddk\6001.18001\inc\api\winbase.h(2409) : error C2084: function 'LONGLONG _
InterlockedExchange64(volatile LONGLONG *,LONGLONG)' already has a body
        c:\winddk\6001.18001\inc\ddk\ntddk.h(4547) : see previous definition of
'_InterlockedExchange64'
c:\winddk\6001.18001\inc\api\winbase.h(2427) : error C2084: function 'LONGLONG _
InterlockedExchangeAdd64(volatile LONGLONG *,LONGLONG)' already has a body
        c:\winddk\6001.18001\inc\ddk\ntddk.h(4567) : see previous definition of
'_InterlockedExchangeAdd64'
c:\winddk\6001.18001\inc\api\winbase.h(2469) : warning C4005: 'InterlockedCompar
eExchangePointer' : macro redefinition
        c:\winddk\6001.18001\inc\ddk\wdm.h(11120) : see previous definition of '
InterlockedCompareExchangePointer'
c:\winddk\6001.18001\inc\api\winbase.h(2495) : error C2375: 'InitializeSListHead
' : redefinition; different linkage
        c:\winddk\6001.18001\inc\ddk\wdm.h(14639) : see declaration of 'Initiali
zeSListHead'
c:\winddk\6001.18001\inc\api\winbase.h(2502) : error C2373: 'InterlockedPopEntry
SList' : redefinition; different type modifiers
        c:\winddk\6001.18001\inc\ddk\wdm.h(14858) : see declaration of 'Interloc
kedPopEntrySList'
c:\winddk\6001.18001\inc\api\winbase.h(2510) : error C2373: 'InterlockedPushEntr
ySList' : redefinition; different type modifiers
        c:\winddk\6001.18001\inc\ddk\wdm.h(14865) : see declaration of 'Interloc
kedPushEntrySList'
c:\winddk\6001.18001\inc\api\winbase.h(2517) : error C2373: 'ExInterlockedFlushS
List' : redefinition; different type modifiers
        c:\winddk\6001.18001\inc\ddk\wdm.h(14849) : see declaration of 'ExInterl
ockedFlushSList'
c:\winddk\6001.18001\inc\api\winbase.h(2524) : error C2059: syntax error : '('
c:\winddk\6001.18001\inc\api\winbase.h(2903) : error C2146: syntax error : missi
ng ')' before identifier 'lpBuffer'
c:\winddk\6001.18001\inc\api\winbase.h(2903) : error C2081: 'PMEMORY_BASIC_INFOR
MATION' : name in formal parameter list illegal
c:\winddk\6001.18001\inc\api\winbase.h(2903) : error C2061: syntax error : ident
ifier 'lpBuffer'
c:\winddk\6001.18001\inc\api\winbase.h(2903) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(2903) : error C2059: syntax error : ','
c:\winddk\6001.18001\inc\api\winbase.h(2905) : error C2059: syntax error : ')'
c:\winddk\6001.18001\inc\api\winbase.h(3016) : error C2146: syntax error : missi
ng ')' before identifier 'lpBuffer'
c:\winddk\6001.18001\inc\api\winbase.h(3016) : error C2081: 'PMEMORY_BASIC_INFOR
MATION' : name in formal parameter list illegal
c:\winddk\6001.18001\inc\api\winbase.h(3016) : error C2061: syntax error : ident
ifier 'lpBuffer'
c:\winddk\6001.18001\inc\api\winbase.h(3016) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(3016) : error C2059: syntax error : ','
c:\winddk\6001.18001\inc\api\winbase.h(3018) : error C2059: syntax error : ')'
c:\winddk\6001.18001\inc\api\winbase.h(3161) : error C2146: syntax error : missi
ng ')' before identifier 'HeapInformationClass'
c:\winddk\6001.18001\inc\api\winbase.h(3161) : error C2081: 'HEAP_INFORMATION_CL
ifier 'HeapInformationClass'
c:\winddk\6001.18001\inc\api\winbase.h(3171) : error C2059: syntax error : ';'
c:\winddk\6001.18001\inc\api\winbase.h(3171) : fatal error C1003: error count exceeded
0
Comment
Question by:supriyaksen
6 Comments
 
LVL 47

Expert Comment

by:dlethe
ID: 40021809
There are a dozen things this could be, from not using the proper compiler environment variables to wrong compiler, to wrong  target (32bit vs 64bit vs WOW), ...  to settings in files included BEFORE the <windows.h>

Best way to get this resolved is to use the DDK and compile one of the simple sample applications and get that to work.  Then you'll know  your runtime./compile environment is correct.

You could publish source code of the entire operation, and people running different system configurations will get different results.
0
 
LVL 34

Accepted Solution

by:
Seth Simmons earned 500 total points
ID: 40021810
that DDK version is for windows 2008 sp1
what version of windows are you running this on?
0
 

Author Comment

by:supriyaksen
ID: 40023205
Yes, I am running this on a windows  8 system. What typical compiler environment variables are used to resolve these issues, and what particular header files need to be included before the windows.h header during compilation? A sample posting of these would be really helpful.

 I am currently using the following complier flags:

cygdrive/c/winddk/6001.18001/bin/x86/x86/cl -nologo -Gz -Zp8 -Ob1 -EHsc -Oi -Zl -Zi -Ox -W4

and the following compiler defines:
-D_X86_ -D_WDM_INCLUDED_ -D_i386_ -D_WIN32 -DWINNT=1 -D_WIN32_WINNT=0x0502 -DWINVER=0x0502 -D_WIN32_IE=0x0603 -D_NTDRIVER_ -D__BUILDMACHINE__=WinDDK  -DCPU=X86 -DQCPU=QX86

Not sure which header file to include before the windows.h file.
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 41626702
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
0
 
LVL 47

Expert Comment

by:dlethe
ID: 41626703
https:#a40021810 is correct answer.  The DDK is specifically designed to work for Win2008, not "Windows 8".
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hallo! I guess almost every Windows Administrator must have got stumped with this question "Where does WINDOWS store a users cached credentials? Every user who had once logged onto a Server/Desktop while it was connected to the domain could sti…
by Nathan Brom/Bromy2004 Introduction There are numerous websites out there for any different type of program you can imagine.  Of those, you'll need to decide which ones are legitimate and aren't trying to steal your money or infect your comput…
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now