Skip to content

[Bug]: Windows build does not work with latest version of Visual Studio #1534

Open

Description

@marcnause

Please check the following before submitting a new issue.

Please select affected platform(s)

  • Android
  • iOS
  • Windows

Steps to reproduce

  1. Use flutter-permission-handler in a Flutter app
  2. Use latest version of Visual Studio (18.6.1)
  3. Try to compile the app for Windows

Expected results

The app compiles and works fine.

Actual results

Compilation fails with the following error:

C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.51.36231\include\experimental\coroutine(37,1): error C2338: static assertion failed: 'error STL1011: The /await compiler option, <experimental/coroutine>, <experimental/generator>, and <experimental/resumable> are deprecated by Microsoft and will be REMOVED SOON. They are superseded by the C++20 <coroutine> and C++23 <generator> headers. You can define _SILENCE_EXPERIMENTAL_COROUTINE_DEPRECATION_WARNINGS to suppress this error for now.' [C:\Users\marcn\pslab-app\build\windows\x64\plugins\permission_handler_windows\permission_handler_windows_plugin.vcxproj]

Code sample

Screenshots or video

Screenshot Image

Version

permission_handler 12.0.1

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.44.0, on Microsoft Windows [Version 10.0.26200.8328], locale de-DE)
[√] Windows Version (Windows 11 or higher, 25H2, 2009)
[X] Android toolchain - develop for Android devices
    X Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/to/windows-android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.

[X] Chrome - develop for the web (Cannot find Chrome executable at "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe")
    ! "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" is not executable.
[√] Visual Studio - develop Windows apps (Visual Studio Community 2026 18.6.1)
[√] Connected device (2 available)
[√] Network resources

! Doctor found issues in 2 categories.

Activity

  1. marcnause commented on May 24, 2026

    @marcnause
    Author

    Removing the following line from permission_handler_windows/windows/CMakeLists.txt made it work for me:

    target_compile_options(${PLUGIN_NAME} PRIVATE /await)

  2. kjxbyz commented on Jun 10, 2026

    @kjxbyz

    Same issue.

    C:\Program Files\Microsoft Visual Studio\18\Enterprise\VC\Tools\MSVC\14.51.36231\include\experimental\coroutine(37,1): error C2338: static assertion failed: 'error STL1011: The /await compiler option, <experimental/coroutine>, <experimental/generator>, and <experimental/resumable> are deprecated by Microsoft and will be REMOVED SOON. They are superseded by the C++20 <coroutine> and C++23 <generator> headers. You can define _SILENCE_EXPERIMENTAL_COROUTINE_DEPRECATION_WARNINGS to suppress this error for now.' [D:\a\picguard\picguard\build\windows\x64\plugins\permission_handler_windows\permission_handler_windows_plugin.vcxproj]
    D:\a\picguard\picguard\build\windows\x64\_deps\sentry-native-src\external\breakpad\src\common\md5.cc(74,23): warning C4267: '+=': conversion from 'size_t' to 'google_breakpad::u32', possible loss of data [D:\a\picguard\picguard\build\windows\x64\_deps\sentry-native-build\external\breakpad_client.vcxproj]
    
  3. kjxbyz commented on Jun 23, 2026

    @kjxbyz

    Workaround until the plugin migrates to C++20 , define the silence macro before the plugins are added in the app's windows/CMakeLists.txt:

    add_compile_definitions(_SILENCE_EXPERIMENTAL_COROUTINE_DEPRECATION_WARNINGS)

  4. agentx-icu commented on Sep 26, 2026

    @agentx-icu

    Another data point, plus the precise mechanism, since the thread has two competing workarounds and only one of them addresses the cause.

    Confirming this on Windows ARM64 and on GitHub-hosted CI. A Flutter app of ours builds Windows x64 and ARM64 in CI. The ARM64 job runs on windows-11-arm, whose image moved to Visual Studio 18 (cl.exe from .../Microsoft Visual Studio/18/Enterprise/VC/Tools/MSVC/14.51.36231/bin/HostARM64/ARM64, Windows SDK 10.0.26100.0), and every build now fails with:

    C:\Program Files\Microsoft Visual Studio\18\Enterprise\VC\Tools\MSVC\14.51.36231\include\experimental\coroutine(37,1): error C2338: static assertion failed: 'error STL1011: The /await compiler option, <experimental/coroutine>, <experimental/generator>, and <experimental/resumable> are deprecated by Microsoft and will be REMOVED SOON. They are superseded by the C++20 <coroutine> and C++23 <generator> headers. You can define _SILENCE_EXPERIMENTAL_COROUTINE_DEPRECATION_WARNINGS to suppress this error for now.' [...\build\windows\x64\plugins\permission_handler_windows\permission_handler_windows_plugin.vcxproj]
    

    Our x64 job still passes only because it is pinned to windows-2022 (MSVC 14.44); the same image family with VS 18 fails on x64 too, as the logs earlier in this thread show. Versions: permission_handler 11.4.0 -> permission_handler_windows 0.2.1, but 0.2.2 and main are identical in the part that matters.

    Minimal repro: any Flutter Windows app that depends on permission_handler, built with VS 18 / MSVC 14.51 (flutter build windows). No plugin API call is needed — it is a compile error in the plugin target.

    Why it happens — the cause is /await, not the C++ standard. C++/WinRT picks its coroutine header on one macro (strings/base_includes.h, unchanged in the pinned Microsoft.Windows.CppWinRT 2.0.210806.1 this plugin generates its headers with):

    #ifdef __cpp_lib_coroutine
    #include <coroutine>
    ...
    #else
    #include <experimental/coroutine>

    MSVC's STL defines __cpp_lib_coroutine only #ifdef __cpp_impl_coroutine (stl/inc/yvals_core.h), and /await selects the pre-standardization coroutine mode instead of the standard one — so permission_handler_windows lands in <experimental/coroutine> even though it already compiles as cxx_std_20, and MSVC 14.51 made that header a hard error.

    We can show both halves of that from one build. The same app also uses audioplayers_windows, which hit the identical STL1011 for a different reason — it requests no standard of its own, so it inherited the Flutter template's cxx_std_17. Raising just that target to cxx_std_20 made its errors disappear, while permission_handler_windows_plugin kept failing at cxx_std_20. The one difference between the two targets is /await.

    That is also why add_compile_definitions(_SILENCE_EXPERIMENTAL_COROUTINE_DEPRECATION_WARNINGS) in the app's windows/CMakeLists.txt "works": it silences the assertion while still compiling against a header Microsoft says is being removed. It buys time, it is not a fix. For the record, what we currently carry in our app is the same stopgap, scoped to this one target so the rest of the app keeps its standard:

    if(TARGET permission_handler_windows_plugin)
      target_compile_features(permission_handler_windows_plugin PRIVATE cxx_std_20)
      target_compile_definitions(permission_handler_windows_plugin
        PRIVATE _SILENCE_EXPERIMENTAL_COROUTINE_DEPRECATION_WARNINGS)
    endif()

    Suggestion: drop /await from the plugin's own windows/CMakeLists.txt — which is exactly what #1569 does (and what #1535 did before it was closed for an unrelated CI check). The target is already cxx_std_20, so co_await in IsBluetoothServiceEnabled compiles through standard <coroutine>; the pinned CppWinRT 2.0.210806.1 already has the __cpp_lib_coroutine branch, so no nuget bump is needed. It is also the only future-proof option: current C++/WinRT replaced that fallback with a hard #error "C++/WinRT no longer supports pre-standardization coroutines. ... If you do not [use co_await], remove /await from the compiler flags.", so /await will stop working regardless of the STL macro.

    For comparison, audioplayers fixed the C++17 variant of this in the plugin package itself (bluefireteam/audioplayers#2011, released in audioplayers_windows 4.4.1) rather than asking apps to patch their CMake — which is the shape of fix that lets apps just upgrade.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions