原因
在编译 qt-everywhere-src-5.15.7 静态的时候,遇到一个error,只能动手查方法了
错误
In file included from ../../include/QtCore/5.15.7/QtCore/private/qorderedmutexlocker_p.h:1,
from io/qprocess_p.h:65,
from io/qprocess.cpp:89:
../../include/QtCore/5.15.7/QtCore/private/../../../../../src/corelib/thread/qorderedmutexlocker_p.h: In constructor ‘QOrderedMutexLocker::QOrderedMutexLocker(QOrderedMutexLocker&&)’:
../../include/QtCore/5.15.7/QtCore/private/../../../../../src/corelib/thread/qorderedmutexlocker_p.h:95:21: error: ‘exchange’ is not a member of ‘std’
95 | : mtx1(std::exchange(other.mtx1, nullptr))
| ^~~~~~~~
../../include/QtCore/5.15.7/QtCore/private/../../../../../src/corelib/thread/qorderedmutexlocker_p.h:96:21: error: ‘exchange’ is not a member of ‘std’
96 | , mtx2(std::exchange(other.mtx2, nullptr))
| ^~~~~~~~
../../include/QtCore/5.15.7/QtCore/private/../../../../../src/corelib/thread/qorderedmutexlocker_p.h:97:23: error: ‘exchange’ is not a member of ‘std’
97 | , locked(std::exchange(other.locked, false))
| ^~~~~~~~
make[3]: *** [Makefile:39413: .obj/qprocess.o] Error 1
make[3]: Leaving directory '/home/wxw/qt-everywhere-src-5.15.7/qtbase/src/corelib'
解决方法:
使用vscode或者其他编辑器,文本文件也行,打开那个报错的文件:
例如我这个:
/qt-everywhere-src-5.15.7/qtbase/src/corelib/thread/qorderedmutexlocker_p.h
打开后,根据行号,更改代码:
原来的代码
// 原来的代码
QOrderedMutexLocker(QOrderedMutexLocker &&other) noexcept
: mtx1(std::exchange(other.mtx1, nullptr))
, mtx2(std::exchange(other.mtx2, nullptr))
, locked(std::exchange(other.locked, false))
{}
更改之后的代码
// 更改之后的代码
// 我还添加了这个头文件 不知道是否有用
// #include <stddef.h>
QOrderedMutexLocker(QOrderedMutexLocker &&other) noexcept
: mtx1(qExchange(other.mtx1, nullptr))
, mtx2(qExchange(other.mtx2, nullptr))
, locked(qExchange(other.locked, false))
{}