Skip to content

Commit

Permalink
COMP: Add template export declaration for ParametricPath
Browse files Browse the repository at this point in the history
The template ParametricPath<2> is explicitly instantiated, but this
instantiation was not correctly marked for export. This caused
duplicate symbol linker errors with Visual Studios and shared
libraries.

Change-Id: Ia2ef618fa8b18453690608d51a6d6670c4d289d7
  • Loading branch information
blowekamp committed Nov 23, 2016
1 parent a7d439c commit a94bc52
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
43 changes: 42 additions & 1 deletion Modules/Filtering/Path/include/itkParametricPath.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "itkContinuousIndex.h"
#include "itkOffset.h"
#include "itkVector.h"
#include "ITKPathExport.h"

namespace itk
{
Expand Down Expand Up @@ -58,7 +59,7 @@ namespace itk
* \ingroup ITKPath
*/
template< unsigned int VDimension >
class ParametricPath:public
class ITKPath_TEMPLATE_EXPORT ParametricPath:public
Path< double, ContinuousIndex< SpacePrecisionType, VDimension >, VDimension >
{
public:
Expand Down Expand Up @@ -143,4 +144,44 @@ class ParametricPath:public
#include "itkParametricPath.hxx"
#endif

#endif // itkParametricPath.h


/** Explicit instantiations */
#ifndef ITK_TEMPLATE_EXPLICIT_ParametricPath
// Explicit instantiation is required to ensure correct dynamic_cast
// behavior across shared libraries.
//
// IMPORTANT: Since within the same compilation unit,
// ITK_TEMPLATE_EXPLICIT_<classname> defined and undefined states
// need to be considered. This code *MUST* be *OUTSIDE* the header
// guards.
//
# if defined( ITKPath_EXPORTS )
// We are building this library
# define ITKPath_EXPORT_EXPLICIT
# else
// We are using this library
# define ITKPath_EXPORT_EXPLICIT ITKCommon_EXPORT
# endif
namespace itk
{

#ifdef ITK_HAS_GCC_PRAGMA_DIAG_PUSHPOP
ITK_GCC_PRAGMA_DIAG_PUSH()
#endif

ITK_GCC_PRAGMA_DIAG(ignored "-Wattributes")

extern template class ITKPath_EXPORT_EXPLICIT ParametricPath< 2 >;

#ifdef ITK_HAS_GCC_PRAGMA_DIAG_PUSHPOP
ITK_GCC_PRAGMA_DIAG_POP()
#else
ITK_GCC_PRAGMA_DIAG(warning "-Wattributes")
#endif


} // end namespace itk
# undef ITKPath_EXPORT_EXPLICIT
#endif
12 changes: 12 additions & 0 deletions Modules/Filtering/Path/src/itkParametricPath.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* limitations under the License.
*
*=========================================================================*/
#define ITK_TEMPLATE_EXPLICIT_MetaDataObject
#include "itkParametricPath.h"

namespace itk
Expand All @@ -25,5 +26,16 @@ namespace itk
// subclass of ParametricPath<2>) and these instantiations must be in
// the library so that the instantiations can be shared amongst
// implicit instantiations of templated subclasses of ParametricPath.
#ifdef ITK_HAS_GCC_PRAGMA_DIAG_PUSHPOP
ITK_GCC_PRAGMA_DIAG_PUSH()
#endif
ITK_GCC_PRAGMA_DIAG(ignored "-Wattributes")

template class ParametricPath< 2 >;

#ifdef ITK_HAS_GCC_PRAGMA_DIAG_PUSHPOP
ITK_GCC_PRAGMA_DIAG_POP()
#else
ITK_GCC_PRAGMA_DIAG(warning "-Wattributes")
#endif
} // end namespace itk

0 comments on commit a94bc52

Please sign in to comment.