Skip to content

Commit 43f435c

Browse files
stuartmorgan-gandroidseb
authored andcommitted
[various] Enable permissive- for Windows plugin examples (flutter#8636)
As the Visual Studio C++ compiler moves toward increasingly standards-compliant behavior, things it allows may become errors in the future (as seen in flutter/flutter#163296 and the issues it references). To avoid a whole class of future problems, this enables `/permissive-` for the example apps of all of our Windows plugins that have native code, and fixes the resulting violations. Fixes flutter/flutter#163296
1 parent 283beed commit 43f435c

File tree

13 files changed

+83
-62
lines changed

13 files changed

+83
-62
lines changed

packages/camera/camera_windows/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## NEXT
1+
## 0.2.6+2
22

3+
* Fixes compile errors under strict standards mode.
34
* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4.
45

56
## 0.2.6+1

packages/camera/camera_windows/example/windows/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ function(APPLY_STANDARD_SETTINGS TARGET)
3434
target_compile_features(${TARGET} PUBLIC cxx_std_17)
3535
target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")
3636
target_compile_options(${TARGET} PRIVATE /EHsc)
37+
# Enable strict standards mode in the example app, since issues it finds
38+
# may become errors by default in future compiler versions.
39+
target_compile_options(${TARGET} PRIVATE /permissive-)
3740
target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0")
3841
target_compile_definitions(${TARGET} PRIVATE "$<$<CONFIG:Debug>:_DEBUG>")
3942
endfunction()

packages/camera/camera_windows/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: camera_windows
22
description: A Flutter plugin for getting information about and controlling the camera on Windows.
33
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_windows
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
5-
version: 0.2.6+1
5+
version: 0.2.6+2
66

77
environment:
88
sdk: ^3.4.0

packages/camera/camera_windows/windows/capture_device_info.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ class CaptureDeviceInfo {
2525

2626
// Parses display name and device id from unique device name format.
2727
// Format: "display_name <device_id>".
28-
bool CaptureDeviceInfo::ParseDeviceInfoFromCameraName(
29-
const std::string& camera_name);
28+
bool ParseDeviceInfoFromCameraName(const std::string& camera_name);
3029

3130
// Updates display name.
3231
void SetDisplayName(const std::string& display_name) {

packages/file_selector/file_selector_windows/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## NEXT
1+
## 0.9.3+4
22

3+
* Fixes compile errors under strict standards mode.
34
* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4.
45

56
## 0.9.3+3

packages/file_selector/file_selector_windows/example/windows/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ function(APPLY_STANDARD_SETTINGS TARGET)
3434
target_compile_features(${TARGET} PUBLIC cxx_std_17)
3535
target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")
3636
target_compile_options(${TARGET} PRIVATE /EHsc)
37+
# Enable strict standards mode in the example app, since issues it finds
38+
# may become errors by default in future compiler versions.
39+
target_compile_options(${TARGET} PRIVATE /permissive-)
3740
target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0")
3841
target_compile_definitions(${TARGET} PRIVATE "$<$<CONFIG:Debug>:_DEBUG>")
3942
endfunction()

packages/file_selector/file_selector_windows/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: file_selector_windows
22
description: Windows implementation of the file_selector plugin.
33
repository: https://github.com/flutter/packages/tree/main/packages/file_selector/file_selector_windows
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+file_selector%22
5-
version: 0.9.3+3
5+
version: 0.9.3+4
66

77
environment:
88
sdk: ^3.4.0

packages/file_selector/file_selector_windows/windows/file_selector_plugin.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,9 @@ ErrorOr<FileDialogResult> ShowDialog(
221221
mode == DialogMode::save ? CLSID_FileSaveDialog : CLSID_FileOpenDialog;
222222
DialogWrapper dialog(dialog_factory, dialog_type);
223223
if (!SUCCEEDED(dialog.last_result())) {
224-
return FlutterError("System error", "Could not create dialog",
225-
EncodableValue(dialog.last_result()));
224+
return FlutterError(
225+
"System error", "Could not create dialog",
226+
EncodableValue(std::in_place_type<int32_t>, dialog.last_result()));
226227
}
227228

228229
FILEOPENDIALOGOPTIONS dialog_options = 0;
@@ -253,8 +254,9 @@ ErrorOr<FileDialogResult> ShowDialog(
253254
std::optional<FileDialogResult> result = dialog.Show(parent_window);
254255
if (!result) {
255256
if (dialog.last_result() != HRESULT_FROM_WIN32(ERROR_CANCELLED)) {
256-
return FlutterError("System error", "Could not show dialog",
257-
EncodableValue(dialog.last_result()));
257+
return FlutterError(
258+
"System error", "Could not show dialog",
259+
EncodableValue(std::in_place_type<int32_t>, dialog.last_result()));
258260
} else {
259261
return FileDialogResult(EncodableList(), nullptr);
260262
}

packages/local_auth/local_auth_windows/example/windows/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ function(APPLY_STANDARD_SETTINGS TARGET)
3434
target_compile_features(${TARGET} PUBLIC cxx_std_17)
3535
target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")
3636
target_compile_options(${TARGET} PRIVATE /EHsc)
37+
# Enable strict standards mode in the example app, since issues it finds
38+
# may become errors by default in future compiler versions.
39+
target_compile_options(${TARGET} PRIVATE /permissive-)
3740
target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0")
3841
target_compile_definitions(${TARGET} PRIVATE "$<$<CONFIG:Debug>:_DEBUG>")
3942
endfunction()

packages/path_provider/path_provider_windows/example/windows/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ function(APPLY_STANDARD_SETTINGS TARGET)
3434
target_compile_features(${TARGET} PUBLIC cxx_std_17)
3535
target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")
3636
target_compile_options(${TARGET} PRIVATE /EHsc)
37+
# Enable strict standards mode in the example app, since issues it finds
38+
# may become errors by default in future compiler versions.
39+
target_compile_options(${TARGET} PRIVATE /permissive-)
3740
target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0")
3841
target_compile_definitions(${TARGET} PRIVATE "$<$<CONFIG:Debug>:_DEBUG>")
3942
endfunction()

0 commit comments

Comments
 (0)