小编Thi*_*ard的帖子

C++ 初始化列表重载消歧

我有一个关于 C++ 初始化列表消歧的问题,它在 gcc、clang 和 Visual Studio 之间表现出不同的行为。

我想知道这是“未定义的行为”(不正确的程序)还是这些编译器之一有错误。任何的想法?

考虑以下声明:

class Arg
{
public:
    Arg(int i);
};

class Object
{
public:
    Object(const char* str, int i);
    Object(const char* str, const std::initializer_list<Arg>& args);
};
Run Code Online (Sandbox Code Playgroud)

现在这种用法:

Object c("c", {4});
Run Code Online (Sandbox Code Playgroud)

应该使用哪个构造函数?一个 with int(假设文字周围的大括号是多余的)或一个带有初始化列表的(隐式转换 from intto Arg)。

GCC 10.2.0 选择具有初始化列表的构造函数Arg

Clang 11.2.2-2 选择构造函数int并报告有关大括号的警告:

initlist.cpp:46:19: warning: braces around scalar initializer [-Wbraced-scalar-init]
    Object c("c", {4});
                  ^~~
Run Code Online (Sandbox Code Playgroud)

Visual Studio 2019 16.8.6 选择int没有警告的构造函数( /W4)。

从多数人的角度来看,具有int胜利的构造函数。另一方面,如果我们直接使用std::initializer_list<int> …

c++ initializer-list compiler-bug

10
推荐指数
1
解决办法
161
查看次数

如何在 ARM64 系统上原生构建适用于 ARM64 的 Windows 11 设备驱动程序?

如何在 ARM64 系统上原生构建适用于 ARM64 的 Windows 11 设备驱动程序?

使用:

  • ARM64 虚拟机上的 Windows 11 21H2(主机:MacBook M1)
  • 视觉工作室17.5.2
  • Windows 驱动程序工具包 10.0.22621.382

我有一个适用于 Windows 11 的简单 WDM 驱动程序。

  • 它在 Windows 11 x64 计算机上原生构建并适用于 x64。
  • 它在 Windows 11 x64 上针对目标 ARM64 进行交叉编译。当在 ARM64 机器上移动生成的二进制文件时,它可以工作。
  • 但是,在 ARM64 系统上本地构建驱动程序会失败。

在 ARM64 上构建相关的用户态应用程序。只有驱动程序无法构建。

构建错误消息是

1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(442,5):
error MSB8020: The build tools for WindowsKernelModeDriver10.0 (Platform Toolset = 'WindowsKernelModeDriver10.0') cannot be found.
To build using the WindowsKernelModeDriver10.0 build tools, please install WindowsKernelModeDriver10.0 build tools.
Alternatively, you may …
Run Code Online (Sandbox Code Playgroud)

wdk device-driver windows-arm64

5
推荐指数
1
解决办法
937
查看次数