Qt6.5.x compilation error: error: C2872: "byte": ambiguous symbol

I have been using Qt5 before, but recently switched to Qt6, compiling a lot of errors.

1. Compilation error:

C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\rpcndr.h:192: error: C2872: “byte”: ambiguous symbol C:\Program Files (x86)\
Windows Kits\10\include\10.0.19041.0\shared\rpcndr.h(192): error C2872: “byte”: ambiguous symbol
C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ shared\rpcndr.h(191): note: may be "unsigned char byte"
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\include\cstddef(28 ): note: or "std::byte"

2. Reason:

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

3. Solution:

Method (1) does not use using namespace std;

Method (2) Add #include <windows.h> before using using namespace std;

For example:

#include <windows.h>
using namespace std;

Guess you like

Origin blog.csdn.net/libaineu2004/article/details/131413997