Isi*_*dor 5 c driver visual-studio visual-studio-2019
我开始开发驱动程序,但是我遵循了一些在这里在线遇到的教程,我正在尝试将我的驱动程序编译成一个简单的 .sys 文件。
代码如下所示:
#include <ntddk.h>
#include <wdf.h>
#define UNREFERENCED_PARAMETER(P) (P)
VOID DriverUnload(PDRIVER_OBJECT driver)
{
DbgPrint("first:HelloWorld End?");
}
NTSTATUS DriverEntry(PDRIVER_OBJECT pDriverObject, PUNICODE_STRING pUnicodeString)
{
DbgPrint("first:HelloWorld Begin?");
pDriverObject->DriverUnload = DriverUnload;
return STATUS_SUCCESS;
}
Run Code Online (Sandbox Code Playgroud)
我得到了这个非常有趣的错误,而不是编译:
Error C2220 warning treated as error - no 'object' file generated MyHelloWorldDriver C:\Users\****\source\repos\MyHelloWorldDriver\MyHelloWorldDriver\main.c 7
Run Code Online (Sandbox Code Playgroud)
我迷路了,因为我不知道还能从哪里寻求答案。我已经检查并检查了所有,我得到了这个有趣的错误,它在其他版本的 Visual Studio 上工作正常。如果我删除警告,我不会担心,它可以正常编译并且不会向我的屏幕发送任何错误,为什么会这样?
我正在使用 Visual Studio 2019,我可能缺少什么?
聚苯乙烯
我得到的警告看起来像这样
Error (active) E1097 unknown attribute "no_init_all" MyHelloWorldDriver C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\km\ntddk.h 372
Error (active) E1097 unknown attribute "no_init_all" MyHelloWorldDriver C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\km\ntddk.h 1093
Warning MSB8038 Spectre mitigation is enabled but Spectre mitigated libraries are not found. Verify that the Visual Studio Workload includes the Spectre mitigated libraries. See https://aka.ms/Ofhn4c for more information. MyHelloWorldDriver C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets 422
Error C2220 warning treated as error - no 'object' file generated MyHelloWorldDriver C:\Users\***\source\repos\MyHelloWorldDriver\MyHelloWorldDriver\main.c 7
Warning C4566 character represented by universal-character-name '\uFF01' cannot be represented in the current code page (1252) MyHelloWorldDriver C:\Users\***\source\repos\MyHelloWorldDriver\MyHelloWorldDriver\main.c 7
Warning C4100 'driver': unreferenced formal parameter MyHelloWorldDriver C:\Users\***\source\repos\MyHelloWorldDriver\MyHelloWorldDriver\main.c 5
Warning C4566 character represented by universal-character-name '\uFF01' cannot be represented in the current code page (1252) MyHelloWorldDriver C:\Users\***\source\repos\MyHelloWorldDriver\MyHelloWorldDriver\main.c 12
Warning C4100 'pUnicodeString': unreferenced formal parameter MyHelloWorldDriver C:\Users\***\source\repos\MyHelloWorldDriver\MyHelloWorldDriver\main.c 10
Run Code Online (Sandbox Code Playgroud)
看起来像 Visual Studio 的问题:https : //developercommunity.visualstudio.com/content/problem/549389/intellisense-error-e1097-because-intellisense-does.html
这是该链接的副本:
在 Visual C++ 2017 版本 15.8(编译器版本 19.15.26726.0)中,新的未记录编译器选项 /d1initall 和新属性 __declspec(no_init_all) 添加到编译器中。Intellisense(VS17 和 19)无法识别此属性并表示未知。
问题是 Intellisense 不知道 no_init_all 属性的存在。
此属性用于官方 Windows SDK 和 WDK 10.0.18362.0 头文件,这意味着 Intellisense 为包含 Windows Kits\10\Include\10.0.18362.0\um\winnt.h(第 588 行和 1093 行)的所有项目显示此错误或 Windows Kits\10\Include\10.0.18362.0\km\ntddk.h(第 7597 行)。
您还可以通过简单地定义具有 __declspec(no_init_all) 属性的结构来重现错误,
__declspec(no_init_all) struct A {}; 这编译得很好,没有任何警告/错误,但 Intellisense 说它错了。
它已于 2019 年 4 月 29 日修复。
一种可能的修复方法是将此代码添加到主头文件之一:
#if (_MSC_VER >= 1915)
#define no_init_all deprecated
#endif
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3610 次 |
最近记录: |