首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 嵌入开发 > 驱动开发 >

张帆驱动开发书里第四章实验 KdPrint 糊涂,该如何处理

2012-04-10 
张帆驱动开发书里第四章实验 KdPrint 糊涂C/C++ codevoid Dump(IN PDRIVER_OBJECT pDriverObject){KdPrint

张帆驱动开发书里第四章实验 KdPrint 糊涂

C/C++ code
void Dump(IN PDRIVER_OBJECT pDriverObject){             KdPrint(("----------------------------------------------\n"));    KdPrint(("开始输出信息...\n"));    KdPrint(("Driver Address:0X%08X\n",pDriverObject));    KdPrint(("Driver name:%wZ\n",&pDriverObject->DriverName));    KdPrint(("Driver HardwareDatabase:%wZ\n",pDriverObject->HardwareDatabase));    KdPrint(("Driver first device:0X%08X\n",pDriverObject->DeviceObject));         int i=1;    PDEVICE_OBJECT pDevice;    pDevice = pDriverObject->DeviceObject;    for (;pDevice!=NULL;pDevice = pDevice->NextDevice)    {        KdPrint(("The %d device\n",i++));        KdPrint(("Device AttachedDevice:0X%08X\n",pDevice->AttachedDevice));        KdPrint(("Device NextDevice:0X%08X\n",pDevice->NextDevice));        KdPrint(("Device StackSize:%d\n",pDevice->StackSize));        KdPrint(("Device's DriverObject:0X%08X\n",pDevice->DriverObject));    }        KdPrint(("输出结束!\n"));    KdPrint(("----------------------------------------------\n"));}


error C2275: 'PDEVICE_OBJECT' : illegal use of this type as an expression 会出现一堆错误
如果我把
int i=1;
PDEVICE_OBJECT pDevice;
pDevice = pDriverObject->DeviceObject;
这三句放到最前面就没事 KdPrint这个宏 有什么特殊的吗? 糊涂 忘高手指点
C/C++ code
void Dump(IN PDRIVER_OBJECT pDriverObject){    int i=1;    PDEVICE_OBJECT pDevice;    pDevice = pDriverObject->DeviceObject;        KdPrint(("----------------------------------------------\n"));    KdPrint(("开始输出信息...\n"));    KdPrint(("Driver Address:0X%08X\n",pDriverObject));    KdPrint(("Driver name:%wZ\n",&pDriverObject->DriverName));    KdPrint(("Driver HardwareDatabase:%wZ\n",pDriverObject->HardwareDatabase));    KdPrint(("Driver first device:0X%08X\n",pDriverObject->DeviceObject));        for (;pDevice!=NULL;pDevice = pDevice->NextDevice)    {        KdPrint(("The %d device\n",i++));        KdPrint(("Device AttachedDevice:0X%08X\n",pDevice->AttachedDevice));        KdPrint(("Device NextDevice:0X%08X\n",pDevice->NextDevice));        KdPrint(("Device StackSize:%d\n",pDevice->StackSize));        KdPrint(("Device's DriverObject:0X%08X\n",pDevice->DriverObject));    }        KdPrint(("输出结束!\n"));    KdPrint(("----------------------------------------------\n"));}


[解决办法]
你别说你是用.c而不是.cpp?????
[解决办法]
用C语言写的,扩展名为.c

对于c代码,必须将变量声明放在函数头部,前面不能有语句。

PDEVICE_OBJECT 的定义


KdPrint使用方法

热点排行