构建期间使用 Qt 时出错:C2872:“字节”:不明确的符号

vla*_*lad 0 c++ qt boost

我有带有编译器 Desktop x86-windows-msvc2019-pe-64bit 的Qt Creator 、Qt Creator 4.11.1 (“基于 Qt 5.14.1 MSVC2017,32 位),于 2020 年 2 月 5 日构建,Boost 库 1.72 以及 Microsoft Visual Studio Express 2019.

在 Qt 中构建程序期间,我收到此错误:

C2872:“字节”:不明确的符号

实际上解决方案写在这个页面上: https ://studiofreya.com/2018/01/06/visual-studio-2017-with-cpp17-and-boost/#stdbyte-ambigously-symbol-and-rpcndr.h问题是我正在使用 Qt (而不是 VS)并且不知道如何关闭此编译器行为。

你知道如何避免这个错误吗?

我的项目文件的开头如下所示:

QT       += core gui
QT       += charts

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++17

# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

INCLUDEPATH += "c:/Qt/boost_1_72_0/"
Run Code Online (Sandbox Code Playgroud)

vla*_*lad 6

正如 Adrian 所建议的 - 为什么 \xe2\x80\x9cusing 命名空间 std;\xe2\x80\x9d 被认为是不好的做法?- 我删掉了

\n\n
using namespace std;\n
Run Code Online (Sandbox Code Playgroud)\n\n

从我的类的头文件中,并在需要的地方使用 std:: 前缀,瞧,错误消失了。

\n