FreeCAD/FreeCAD

Windows: MSVC Compiler Warning: `boost::signals2::scoped_connection` needs to have dll-interface to be used by clients of `Gui::DocumentObserver`

クローズ

#22,139 opened on 2025/06/23

 (0 件のコメント) (0 件のリアクション) (0 人の担当者)C++ (5,550 件のフォーク)batch import
Good first issueOS: WindowsPackaging/buildingType: Feature

Repository metrics

Stars
 (30,913 個のスター)
PR merge metrics
 (平均マージ 24d 7h) (30d で 217 merged PRs)

説明

Is there an existing issue for this?

  • I have searched the existing issues

Problem description

The DocumentObserver class defined in src/Gui/DocumentObserver.h has ten private member variables that are of type boost::signals2::scoped_connection. Boost deliberately does not export these symbols with a DLL interface, and so MSVC warns about them, e.g.

G:\FreeCAD\FreeCAD\src\Gui/DocumentObserver.h(368): warning C4251: 'Gui::DocumentObserver::connectDocumentDelete': 'boost::signals2::scoped_connection' needs to have dll-interface to be used by clients of 'Gui::DocumentObserver'
G:\FreeCAD\FreeCAD-LibPack-chennes\working\LibPack-1.1.0-v3.1.1.3-Release\include\boost-1_87\boost/signals2/connection.hpp(314): note: see declaration of 'boost::signals2::scoped_connection'

Because of the way we compile FreeCAD this does not represent a real problem, since all FC DLLs are compiled at the same time, by the same compiler, etc. so there can't be a binary incompatibility. However, the compiler warning is annoying. We probably shouldn't completely disable it, since sometimes it does indicate a real problem. One solution would be to move all of those connection variables into a private implementation class defined in the *.cpp file.

Full version info

https://github.com/FreeCAD/FreeCAD/commit/71eed18cb161bdb23341bfe7f907fa7c4bd21230

Subproject(s) affected?

None

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

コントリビューターガイド