Qt6.5.x编译报错:error: C2872: “byte”: 不明确的符号

以前一直用Qt5,最近切换Qt6,编译一大堆报错。

1、编译报错:

C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\rpcndr.h:192: error: C2872: “byte”: 不明确的符号
C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared\rpcndr.h(192): error C2872: “byte”: 不明确的符号
C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared\rpcndr.h(191): note: 可能是“unsigned char byte”
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\include\cstddef(28): note: 或    “std::byte”

2、原因:

std::byte ambiguous symbol and rpcndr.h
There is actually a conflict between C++17 and one Windows header.

3、解决办法:

方法(1)不使用using namespace std;

方法(2)在使用using namespace std;之前,添加#include <windows.h>

例如:

#include <windows.h>
using namespace std;

猜你喜欢

转载自blog.csdn.net/libaineu2004/article/details/131413997