diff --git a/mkspecs/features/common_pre.prf b/mkspecs/features/common_pre.prf index 206230870..4257e088b 100644 --- a/mkspecs/features/common_pre.prf +++ b/mkspecs/features/common_pre.prf @@ -175,6 +175,12 @@ defineTest(addLibraryDependency) { } } +################################ +# Workarounds needed when using MSVC /permissive- flag +################################ + +msvc:contains(QMAKE_CXXFLAGS, /permissive-): QMAKE_CXXFLAGS *= /FIpermissiveworkarounds.h + ################################ # Experimental support for Clang on Windows ################################ diff --git a/src/blackcore/application.cpp b/src/blackcore/application.cpp index 0228ac331..a69313302 100644 --- a/src/blackcore/application.cpp +++ b/src/blackcore/application.cpp @@ -70,6 +70,9 @@ #include #ifdef BLACK_USE_CRASHPAD +#if defined(Q_OS_WIN) && !defined(NOMINMAX) +#define NOMINMAX +#endif #include "crashpad/client/crashpad_client.h" #include "crashpad/client/crash_report_database.h" #include "crashpad/client/settings.h" diff --git a/src/blackmisc/metaclass.h b/src/blackmisc/metaclass.h index 25ee2f499..a2d86e0e0 100644 --- a/src/blackmisc/metaclass.h +++ b/src/blackmisc/metaclass.h @@ -279,7 +279,8 @@ namespace BlackMisc template using index = std::integral_constant; - constexpr static auto members() { return MetaClass::getMemberList(); } + // Trailing return type needed to work around MSVC "function returning auto can not be used before it has been defined" with /permissive- + constexpr static auto members() -> decltype(MetaClass::getMemberList()) { return MetaClass::getMemberList(); } }; namespace Private diff --git a/src/blackmisc/processinfo.cpp b/src/blackmisc/processinfo.cpp index a6e1c5f94..65b0d5b38 100644 --- a/src/blackmisc/processinfo.cpp +++ b/src/blackmisc/processinfo.cpp @@ -15,6 +15,9 @@ #if defined(Q_OS_MACOS) #include #elif defined(Q_OS_WIN) +#ifndef NOMINMAX +#define NOMINMAX +#endif #include #include #endif diff --git a/src/permissiveworkarounds.h b/src/permissiveworkarounds.h new file mode 100644 index 000000000..af97cadd5 --- /dev/null +++ b/src/permissiveworkarounds.h @@ -0,0 +1,14 @@ +/* Copyright (C) 2018 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +//! \file + +// Workaround for "unexpected token 'identifier'" in combaseapi.h when compiling with /permissive- +// https://developercommunity.visualstudio.com/solutions/187139/view.html +struct IUnknown; diff --git a/src/xswiftbus/datarefs.h b/src/xswiftbus/datarefs.h index 70c8fb7bd..daf3c71a5 100644 --- a/src/xswiftbus/datarefs.h +++ b/src/xswiftbus/datarefs.h @@ -165,7 +165,7 @@ namespace XSwiftBus //! Set the value of part of the string (if it is writable) void setSubstr(size_t offset, std::string const &s) - { assert((s.size() + 1) <= (DataRefTraits::size - offset)); XPLMSetDatab(m_ref, s.c_str(), offset, s.size() + 1); } + { assert((s.size() + 1) <= (DataRefTraits::size - offset)); XPLMSetDatab(m_ref, (void *)s.c_str(), (int)offset, (int)s.size() + 1); } //! Get the value of part of the string std::string getSubstr(size_t offset, size_t size) const