Forked from
Core Modules / dune-common
Source project has a limited visibility.
-
Steffen Müthing authored
This patch adds a new header visibility.hh with macros DUNE_EXPORT and DUNE_PRIVATE to mark symbols as exported or private at the ABI level. While we do not explicitly mark any symbols as hidden, there are certain situations in which the compiler creates symbols with incorrect linkage, especially for singleton accessor methods for templated types and their embedded static variables, which involve the creation of weak symbols. The linker is then unable to merge those weak definitions, causing either a link-time failure (when building static libraries) or undefined runtime behaviour (dynamic libraries). This problem can be avoided by explicitly marking the singleton accessor methods as DUNE_EXPORT. For symmetry, there is also a DUNE_PRIVATE macro, but while it works, I don't see it used very much in the short term.
Steffen Müthing authoredThis patch adds a new header visibility.hh with macros DUNE_EXPORT and DUNE_PRIVATE to mark symbols as exported or private at the ABI level. While we do not explicitly mark any symbols as hidden, there are certain situations in which the compiler creates symbols with incorrect linkage, especially for singleton accessor methods for templated types and their embedded static variables, which involve the creation of weak symbols. The linker is then unable to merge those weak definitions, causing either a link-time failure (when building static libraries) or undefined runtime behaviour (dynamic libraries). This problem can be avoided by explicitly marking the singleton accessor methods as DUNE_EXPORT. For symmetry, there is also a DUNE_PRIVATE macro, but while it works, I don't see it used very much in the short term.