G_NO_INLINE macro definition detected incorrectly in MSVC 2019 c++17
Describe your issue
On cross-platform builds with QtCreator qmake, configuration set to MSVC 64-bit 2019, the G_NO_INLINE macro is detected incorrectly and some open-source projects with Werror fail unexpectedly with gstreamer 1.22.1 headers. This is a build compatibility issue.
QGroundControl-master\libs\qmlglsink\gst-plugins-good\ext\qt\gstqtsrc.cc:76: warning: C5051: attribute 'noinline' requires at least '/std:c++20'; ignored
QGroundControl-master\libs\qmlglsink\gst-plugins-good\ext\qt\gstqtsrc.cc:76: error: C2220: the following warning is treated as an error
I suggest treating MSVC as the special snowflake that it is, and always use the backward-compatible __declspec(noinline)
in gmacros.h
:
#if defined (_MSC_VER)
# define G_NO_INLINE __declspec(noinline)
#elif ...
Expected Behavior
Gstreamer headers should be backward compatible with open-source projects because this can create incredibly difficult-to-track errors in unrelated projects.
Observed Behavior
Rare compilation failure of a previously working project, due to gstreamer 1.22.1 headers.
Setup
- Windows 10, MSVC 2019
- MSVC 64-bit (VS 2019, Release CRT) 1.22.1 development installer
- Build command line flags for cl.exe, generated by qmake:
cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -MP /std:c++17 -O2 -Zi -MD /Gy /Zo -std:c++17 -GL -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 /WX /W3 /wd4005 /wd4290 /wd4267 /wd4100 -EHsc /FdQGroundControl.vc.pdb -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DWIN64 -DQGC_GST_TAISYNC_DISABLED -D__STDC_LIMIT_MACROS -DQGC_GST_MICROHARD_ENABLED -DDAILY_BUILD -DAPP_VERSION_STR="\"v4.2.0-375-g9491315a7\"" -DEIGEN_MPL2_ONLY -D_TTY_NOWARN_ -DQT_NO_DEBUG -DQT_MESSAGELOGCONTEXT -DQGC_DISABLE_PAIRING -DQGC_USE_ARDUPILOTMEGA_MESSAGES -DNOMINMAX -DXZ_DEC_ANY_CHECK -DXZ_USE_CRC64 -DQGC_APPLICATION_NAME="\"QGroundControl\"" -DQGC_ORG_NAME="\"QGroundControl.org\"" -DQGC_ORG_DOMAIN="\"org.qgroundcontrol\"" -DQGC_GST_STREAMING -DHAVE_QT_WIN32 -DHAVE_QT_QPA_HEADER -DNDEBUG -DQT_NO_DEBUG -DQT_LOCATION_LIB -DQT_POSITIONINGQUICK_LIB -DQT_QUICKCONTROLS2_LIB -DQT_QUICKWIDGETS_LIB -DQT_QUICK_LIB -DQT_OPENGL_LIB -DQT_SVG_LIB -DQT_CHARTS_LIB -DQT_WIDGETS_LIB -DQT_MULTIMEDIA_LIB -DQT_GUI_LIB -DQT_CONCURRENT_LIB -DQT_POSITIONING_LIB -DQT_QMLMODELS_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_SQL_LIB -DQT_XML_LIB -DQT_TEXTTOSPEECH_LIB -DQT_SERIALPORT_LIB -DQT_TESTLIB_LIB -DQT_CORE_LIB
Steps to reproduce the bug
- Compile an application with MSVC 2019 64-bit flags: /std:c++17 /WX
- Use G_NO_INLINE macro on any function
- Observe as the macros detect that [[msvc::noinline]] can be used with the compiler, however, the compiler is in /std:c++17 standard, so the
[[msvc::noinline]]
attribute is actually not supported.
How reproducible is the bug?
It is always reproduced.
Solutions you have tried
Manually fixing the gmacros.h header works, but it would be best if gstreamer latest headers were fixed