[permission_handler_windows] Fix clang-cl compilation - #1518
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves compatibility with clang-cl (LLVM) compiler for the Windows permission handler plugin by making implicit type conversions explicit and cleaning up compiler warnings. The changes ensure the plugin builds successfully with both clang-cl and MSVC.
Changes:
- Made
EncodableValuetype conversion explicit when passingEncodableMaptoresult->Success() - Removed unused
[this]lambda capture that caused warnings in clang-cl - Updated version numbers for both
permission_handler_windows(0.2.1 → 0.2.2) andpermission_handler(12.0.1 → 12.0.2)
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| permission_handler_windows/windows/permission_handler_windows_plugin.cpp | Explicit EncodableValue conversion and removed unused lambda capture |
| permission_handler_windows/pubspec.yaml | Version bump to 0.2.2 |
| permission_handler_windows/CHANGELOG.md | Added changelog entry for clang-cl support |
| permission_handler/pubspec.yaml | Version bump to 12.0.2 and updated Windows dependency |
| permission_handler/CHANGELOG.md | Added changelog entry for Windows compatibility update |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ## 0.2.2 | ||
|
|
||
| * clang-cl support | ||
| * Explicit Type Conversion: Wrapped `requestResults` in `flutter::EncodableValue(...)` before passing it to `result->Success() |
There was a problem hiding this comment.
Missing closing backtick after result->Success(). The line should end with a closing backtick to properly format the inline code.
| * Explicit Type Conversion: Wrapped `requestResults` in `flutter::EncodableValue(...)` before passing it to `result->Success() | |
| * Explicit Type Conversion: Wrapped `requestResults` in `flutter::EncodableValue(...)` before passing it to `result->Success()` |
MSVC accepts the implicit conversion from EncodableMap to EncodableValue when calling MethodResult::Success(), but clang-cl does not and fails with "no matching member function for call to 'Success'". Wrap the map in an explicit flutter::EncodableValue, which compiles under both toolchains. Also drops an unused `this` capture from the Geolocator.PositionChanged lambda, which clang-cl reports as -Wunused-lambda-capture. Bumps permission_handler_windows to 0.2.3. The app-facing package needs no change: its existing `permission_handler_windows: ^0.2.2` constraint already allows 0.2.3. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Rebuilt this branch on top of current Summary of what changed since the last revision:
The PR is now three files, all inside |
Flutter's generated app compiles plugins with /W4 /WX, and two things in this file fail that under clang-cl: * the request loop compared an int index against permissions.size(); * the PositionChanged handler ignores both of its parameters. MSVC stays quiet because Flutter passes /wd"4100", but clang-cl does not apply that quoted form and errors with -Wunused-parameter. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Description
This PR fixes compilation of the Windows plugin with
clang-cl(LLVM), which some projects use for faster Windows builds.MSVC accepts the implicit conversion from
EncodableMaptoEncodableValuewhen callingMethodResult::Success().clang-clis stricter and rejects it.Reproduction
Configured the way a project on the LLVM toolset does —
/W3,-Wno-error— compiling the plugin target against the released 0.2.2 package with no patches applied:Applying only the
Success(flutter::EncodableValue(...))change from this PR, and altering nothing else, that target compiles. This is an overload-resolution error, not a warning, so no-Wno-...flag makes it go away — a project on clang-cl currently cannot build this package without patching it locally.Changes
Scoped entirely to
permission_handler_windows, and to that one file:requestResultsinflutter::EncodableValue(...)before passing it toresult->Success().no matching member function for call to 'Success'/W4 /WXsettings Flutter generates for every Windows app:thiscapture and the unused parameter names from theGeolocator.PositionChangedlambda — clang-cl reports these as-Wunused-lambda-captureand-Wunused-parameter(MSVC stays quiet on the latter because Flutter passes/wd"4100", a quoted form clang-cl does not apply);size_tindex, fixing the signed/unsigned comparison.permission_handler_windowsto0.2.3with aCHANGELOG.mdentry.The app-facing
permission_handlerpackage is deliberately not touched: its existingpermission_handler_windows: ^0.2.2constraint already allows 0.2.3.Testing
Success()call, which these changes make unnecessary./awaitline removed locally,flutter build windows --releaseof the example builds the whole app on MSVC 14.51. Left in place, the package still fails there for the pre-existing reason in note 2 below — that is not something this PR changes either way.requestPermissionsstill returns correct results on Windows.Related Issue
Fixes build failures for users compiling the Windows plugin with
clang-cl.Pre-launch Checklist
pubspec.yamlwith an appropriate new version according to the pub versioning philosophy.CHANGELOG.mdto add a description of the change.///).main.dart format .and committed any changes.flutter analyzeand fixed any errors.