Skip to content

window_manager: On windows, build fails on 0.7.2 (cnativeapi 0.6.3): 'min'/'max': identifier not found in GdiplusTypes.h #77

Done
libnativeapi/nativeapi-core
#113

Description

@filiph

First of all, thanks for the window_manager package! It's been very helpful since I have little understanding of native desktop windowing APIs.

Today, my build on windows crashed. What follows is an AI agent's attempt at writing an issue. Sorry for this, but I don't think I can match the LLM in understanding the problem, so I won't try to touch the text.


Package version: window_manager: 0.7.2 / cnativeapi: 0.6.3
Platform: Windows (MSVC / Visual Studio 2022, Windows 10 SDK)

Description:

Building a Windows Flutter app fails after upgrading to window_manager: 0.7.2 (which brings in cnativeapi: 0.6.3).

The build fails during flutter_assemble / native assets compilation with:

C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um\GdiplusTypes.h(479): error C3861: 'min': identifier not found
C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um\GdiplusTypes.h(481): error C3861: 'max': identifier not found
Target build_hooks failed : error : Building native assets failed.

Cause:

In cnativeapi 0.6.3, cxx_impl/src/platform/windows/window_taskbar_windows.cpp was added with:

// clang-format off
#include <windows.h>
#include <commctrl.h>
#include <dwmapi.h>
#include <gdiplus.h>
#include <shobjidl.h>
// clang-format on

Because Flutter's native asset compilation under MSVC defines NOMINMAX, the Windows SDK's <gdiplus.h> / <GdiplusTypes.h> cannot resolve min and max.

In other files like view_windows.cpp and view_winui3_windows.cpp, this is handled by:

#include <algorithm>
using std::max;
using std::min;
#include <gdiplus.h>

Adding using std::max; using std::min; before #include <gdiplus.h> in window_taskbar_windows.cpp fixes the issue.

Workaround:
Pin window_manager to 0.7.1 and cnativeapi to 0.6.2 in dependency_overrides.

Activity

  1. filiph commented on Dec 2, 2026

    @filiph
    Author

    Update: This actually affects all 0.6.x versions of cnativeapi (including 0.6.2), not just 0.6.3.

    In addition to window_taskbar_windows.cpp, the following files also #include <gdiplus.h> directly without using std::min; using std::max; under NOMINMAX:

    • cxx_impl/src/platform/windows/image_windows.cpp
    • cxx_impl/src/platform/windows/clipboard_windows.cpp
    • cxx_impl/src/platform/windows/drag_source_windows.cpp

    All of them fail with error C3861: 'min'/'max': identifier not found in GdiplusTypes.h. Adding <algorithm> and using std::min; using std::max; (as is done in view_windows.cpp) to all four files is needed to resolve the Windows build.

  2. lijy91 commented on Dec 2, 2026

    @lijy91
    Member

    Thanks for the clear report @filiph!

    Fixed in libnativeapi/nativeapi-core#113 and #78: #include <algorithm> with using std::max; using std::min; has been added before #include <gdiplus.h> in window_taskbar_windows.cpp as well as the other remaining Windows source files that include <gdiplus.h> (clipboard_windows.cpp, drag_source_windows.cpp, image_windows.cpp, menu_winui3_windows.cpp), matching view_windows.cpp and view_winui3_windows.cpp.

    This fix will be included in the next cnativeapi / nativeapi patch release.

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