Fix MSVC duplicate symbol errors for PrimitiveDistance#237
Merged
Conversation
…alizations Add explicit specialization declarations in primitive_distance.hpp for the seven methods that have optimized definitions in primitive_distance.cpp (compute_closest_direction_hessian for Edge3/Edge3, Point2/Point2, Point3/Point3; compute_mollifier_gradient and compute_mollifier_hessian for Edge3/Edge3 and Face/Point3). Without these declarations, MSVC instantiates the inline primary template body in every including translation unit, producing duplicate symbol linker errors. GCC/Clang handle this via COMDAT merging; MSVC does not. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses MSVC linker duplicate-symbol errors for PrimitiveDistance by ensuring certain optimized member-function specializations (defined in primitive_distance.cpp) are declared in the header so other translation units don’t implicitly instantiate the primary inline definitions.
Changes:
- Added explicit specialization declarations for 7 optimized
PrimitiveDistance<...>member functions. - Guarded the declarations with
#ifndef IPC_TOOLKIT_DEBUG_AUTODIFFto match the existing conditional compilation of the optimized definitions inprimitive_distance.cpp.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #237 +/- ##
==========================================
+ Coverage 95.75% 96.49% +0.73%
==========================================
Files 163 163
Lines 16650 16649 -1
Branches 920 921 +1
==========================================
+ Hits 15944 16066 +122
+ Misses 706 583 -123
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add explicit specialization declarations in primitive_distance.hpp for the seven methods that have optimized definitions in primitive_distance.cpp (compute_closest_direction_hessian for Edge3/Edge3, Point2/Point2, Point3/Point3; compute_mollifier_gradient and compute_mollifier_hessian for Edge3/Edge3 and Face/Point3). Without these declarations, MSVC instantiates the inline primary template body in every including translation unit, producing duplicate symbol linker errors. GCC/Clang handle this via COMDAT merging; MSVC does not.
Type of change