You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
window_manager: On windows, build fails on 0.7.2 (cnativeapi 0.6.3): 'min'/'max': identifier not found in GdiplusTypes.h #77
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.
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:
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.
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.
Activity
filiph commentedon Dec 2, 2026
Update: This actually affects all
0.6.xversions ofcnativeapi(including0.6.2), not just0.6.3.In addition to
window_taskbar_windows.cpp, the following files also#include <gdiplus.h>directly withoutusing std::min; using std::max;underNOMINMAX:cxx_impl/src/platform/windows/image_windows.cppcxx_impl/src/platform/windows/clipboard_windows.cppcxx_impl/src/platform/windows/drag_source_windows.cppAll of them fail with
error C3861: 'min'/'max': identifier not found in GdiplusTypes.h. Adding<algorithm>andusing std::min; using std::max;(as is done inview_windows.cpp) to all four files is needed to resolve the Windows build.lijy91 commentedon Dec 2, 2026
Thanks for the clear report @filiph!
Fixed in libnativeapi/nativeapi-core#113 and #78:
#include <algorithm>withusing std::max; using std::min;has been added before#include <gdiplus.h>inwindow_taskbar_windows.cppas 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), matchingview_windows.cppandview_winui3_windows.cpp.This fix will be included in the next
cnativeapi/nativeapipatch release.