d_iyui
驱动牛犊
驱动牛犊
  • 注册日期2002-10-28
  • 最后登录2005-01-21
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:1304回复:3

extern \"C\" { include <WDM.H> }

楼主#
更多 发布于:2002-11-08 23:04
为什么要这么写?写 include <WDM.H>不可以吗?还有

Build Log

--------------------Configuration: temp - Win32 Debug--------------------

Command Lines
Creating temporary file \"H:\\DOCUME~1\\JOHNZH~1\\LOCALS~1\\Temp\\RSP2F2D.tmp\" with contents
[
/nologo /Gz /MLd /W3 /Gm /Gi /Zi /Od /I \"\\NTDDK\\inc\" /D DBG=1 /D \"_X86_\" /D _WIN32_WINNT=0x500 /FR\"Debug/\" /Fp\"Debug/temp.pch\" /YX /Fo\"Debug/\" /Fd\"Debug/\" /FD /Gs -GF /c
\"D:\\temp\\Driver.cpp\"
\"D:\\temp\\EventLog.cpp\"
\"D:\\temp\\Unicode.cpp\"
]
Creating command line \"cl.exe @H:\\DOCUME~1\\JOHNZH~1\\LOCALS~1\\Temp\\RSP2F2D.tmp\"
Creating temporary file \"H:\\DOCUME~1\\JOHNZH~1\\LOCALS~1\\Temp\\RSP2F2E.tmp\" with contents
[
int64.lib ntoskrnl.lib hal.lib /nologo /base:\"0x10000\" /entry:\"DriverEntry\" /incremental:no /pdb:\"Debug/temp.pdb\" /debug /machine:I386 /nodefaultlib /out:\"Debug\\temp.SYS\" /pdbtype:con /libpath:\"\\NTDDK\\libchk\\i386\" -driver -subsystem:NATIVE,4.00
.\\Debug\\Driver.obj
.\\Debug\\EventLog.obj
.\\Debug\\Unicode.obj
.\\Debug\\Msg.res
]
Creating command line \"link.exe @H:\\DOCUME~1\\JOHNZH~1\\LOCALS~1\\Temp\\RSP2F2E.tmp\"
Creating temporary file \"H:\\DOCUME~1\\JOHNZH~1\\LOCALS~1\\Temp\\RSP2F2F.bat\" with contents
[
@echo off
copy .\\Debug\\temp.SYS H:\\WINNT\\System32\\Drivers\\*.*
]
Creating command line \"H:\\DOCUME~1\\JOHNZH~1\\LOCALS~1\\Temp\\RSP2F2F.bat\"
Compiling...
Driver.cpp
F:\\NTDDK\\INC\\WDM.h(354) : error C2146: syntax error : missing \';\' before identifier \'Lock\'
F:\\NTDDK\\INC\\WDM.h(354) : error C2501: \'PULONG_PTR\' : missing storage-class or type specifiers
F:\\NTDDK\\INC\\WDM.h(354) : error C2501: \'Lock\' : missing storage-class or type specifiers
F:\\NTDDK\\INC\\WDM.h(594) : error C2146: syntax error : missing \';\' before identifier \'KSPIN_LOCK\'
F:\\NTDDK\\INC\\WDM.h(594) : fatal error C1004: unexpected end of file found
EventLog.cpp
F:\\NTDDK\\INC\\WDM.h(354) : error C2146: syntax error : missing \';\' before identifier \'Lock\'
F:\\NTDDK\\INC\\WDM.h(354) : error C2501: \'PULONG_PTR\' : missing storage-class or type specifiers
F:\\NTDDK\\INC\\WDM.h(354) : error C2501: \'Lock\' : missing storage-class or type specifiers
F:\\NTDDK\\INC\\WDM.h(594) : error C2146: syntax error : missing \';\' before identifier \'KSPIN_LOCK\'
F:\\NTDDK\\INC\\WDM.h(594) : fatal error C1004: unexpected end of file found
Unicode.cpp
F:\\NTDDK\\INC\\DDK\\NTDDK.h(370) : error C2146: syntax error : missing \';\' before identifier \'Lock\'
F:\\NTDDK\\INC\\DDK\\NTDDK.h(370) : error C2501: \'PULONG_PTR\' : missing storage-class or type specifiers
F:\\NTDDK\\INC\\DDK\\NTDDK.h(370) : error C2501: \'Lock\' : missing storage-class or type specifiers
F:\\NTDDK\\INC\\DDK\\NTDDK.h(824) : error C2146: syntax error : missing \';\' before identifier \'KSPIN_LOCK\'
F:\\NTDDK\\INC\\DDK\\NTDDK.h(824) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
Output Window
Creating command line \"bscmake.exe /nologo /o\"Debug/temp.bsc\"  .\\Debug\\Driver.sbr .\\Debug\\EventLog.sbr .\\Debug\\Unicode.sbr\"
Output Window



Results
temp.SYS - 15 error(s), 0 warning(s)

为什么会这样?WDM.H NTDDK.H没有错呀,他怎么就编译通不过呢?
原文件就是这样的:

#pragma once
extern \"C\" {
#include <WDM.h>
}
#include \"Unicode.h\"
#include \"EventLog.h\"
#include \"Msg.h\"
谁告诉我为什么??
环境:win2000professional+win2000ddk+vc6.0
zydcat
驱动老牛
驱动老牛
  • 注册日期2001-12-06
  • 最后登录2006-04-12
  • 粉丝0
  • 关注0
  • 积分9分
  • 威望2点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2002-11-09 09:51
因为你的文件用到c++的语法
所以需要用Extern“c”将wdm.h包起来
[color=red]肥虫虫[/color] [img]http://www.driverdevelop.com/forum/upload/bradley/2002-11-15_ig01.gif[/img]
VanCheer
驱动老牛
驱动老牛
  • 注册日期2002-02-21
  • 最后登录2003-08-28
  • 粉丝0
  • 关注0
  • 积分-20分
  • 威望-10点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2002-11-09 10:11
因为wdm.h是C的
[img]http://www.driverdevelop.com/forum/upload/VanCheer/2003-03-21_mon.gif[/img][img]http://www.driverdevelop.com/forum/upload/VanCheer/2002-12-07_smallbaby.jpg[/img]
vsim
驱动牛犊
驱动牛犊
  • 注册日期2002-10-09
  • 最后登录2003-09-12
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
地板#
发布于:2002-11-09 10:41
你include 了wdm.h和ntddk.h,但是他们的顺序应该放在所有其它路径的前面
具体的做法是在VC中增加两个路径:D:|ntddk\\inc和D:\\ntddk\\inc\\ddk,并把他们放到所有路径的最上面.
编译顺序很重要.
FPGA/ASIC/WDM/EDASoftware/WLAN/ARM/C,......
游客

返回顶部