Fix MSVC 14.5+ compilation error in Point.cpp#1027
Merged
mfisher31 merged 1 commit intokushview:mainfrom Jan 6, 2026
Merged
Conversation
Isolate C linkage from C++ lambda code and fix missing brace in distanceSquared overload. Modern MSVC enforces stricter linkage rules for lambdas with explicit return types in extern "C" functions.
Member
|
Welp, didn't get to this quite yet today. I need to check it on my release-builder since it is using an older MSVC. Can't be breaking those :) |
Member
|
Hey @bzeiss - I cleaned some stuff up and pushed to a temporary branch so the builds can run: https://github.com/kushview/element/actions/runs/20757208248 This PR was made before I setup github actions.. If that passes, I'll merge it and will automatically "merge" this PR. Thanks! |
Member
|
My additions here: b34d306 |
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.
Note: #1025 seems required as well to build on MSVC 14.5+. This change was tested on top of 1025.
Fix Point.cpp compilation error on modern MSVC toolsets
1. What has been changed
Change #1: Fixed missing closing brace
}to close the second lambda indistanceSquaredsol::overloadChange #2: Separated C and C++ linkage
2. Why it has been changed / Points addressed
Compilation failure on MSVC 14.5+:
Modern MSVC toolsets (14.5+) enforce stricter C++20 linkage rules. The lambda with explicit return type
-> PTFinside theextern "C"function luaopen_el_Point() was being interpreted as having C linkage itself, which cannot return C++ class types.The missing brace caused cascading parse errors that made the root cause harder to identify initially.
6. Impact on cross-platform compatibility
Windows MSVC:
Other platforms:
This appears to be a Windows-specific issue where newer MSVC is correctly enforcing standards compliance that other compilers may handle more leniently.
9. Alternative approaches considered
Option A: Remove explicit return type (not taken)
Option B: Wrapper function (taken)
10. Test recommendations
All existing tests pass (33/33). Specific validation:
Recommended additional testing:
rotated()method specifically since that was the lambda triggering the error11. Open Issues / Things to critically consider
Consistency across codebase:
Other
luaopen_*functions in src/el/ may have similar patterns with lambdas inside extern "C" functions. I did not encounter build errors from those files, but they might be worth reviewing for consistency or potential future issues on even stricter compilers.