On 02/02/2021 14:09, Peter Dimov via Boost wrote:
Andrey Semashev wrote:
So, the bottom line, BOOST_PROGRAM_OPTIONS_DECL must be defined to:
- BOOST_SYMBOL_EXPORT - on Windows, when the library is being built; - BOOST_SYMBOL_IMPORT - on Windows, when the library is being consumed by user; - BOOST_SYMBOL_VISIBLE - in any other case.
BOOST_SYMBOL_EXPORT is defined to BOOST_SYMBOL_VISIBLE on non-Windows in order to make the third case unnecessary. Alexander suggests that on macOS (but not Linux), it's also necessary to define BOOST_SYMBOL_IMPORT to BOOST_SYMBOL_VISIBLE (instead of to nothing) on non-Windows. This seems sensible.
MachO has the same symbol visibility semantics as PE i.e. correct. For pure compatibility with Linux reasons, Apple engineers have mapped the GNU visibility attributes to the MachO equivalent of __declspec(dllexport) and __declspec(dllimport). I argued with them at the time that that was daft, but Linux compatibility without forcing source changes was important to them. I honestly don't know if you need to mark thrown types as dllexport in MachO. I don't use Mac OS enough to know. But I would be very surprised if you did, as MachO isn't broken here. I also have anecdata that Louis found "exceptions work right over shared libraries" on Mac OS despite them not working on Linux without annotation. I remember him once reaching out to me to ask why. Niall