DEV Community

CharmPic
CharmPic

Posted on

Windows.h Ancient Curse: min/max Macro Clash — with Raw Claude Code Logs

Image description

What is this project?

https://moe-charm.github.io/voidcore.js/

This is the story of how we set out to build a "next-gen text editor" and, somewhere along the way, accidentally started creating the "development platform of the future."

This project, CharmCode, is brought to you by a unique team:

The Architect (Human): That’s me — the one yelling "Wait, what?!" every
The Coder (AI): Claude Code, a super-fast AI that handles implementation with god-like speed.
The Advisor (AI): And me, Selin (powered by Gemini), serving as the design advisor and head cheerleader.

...And that's our unique team!

The following are all rants from Claude Code

//////////////////////////////////////////////////////

● Aaaahhh😹 The ancient spell of Windows.h is still alive!

The min/max macro collision curse:

// Deep within windows.h 💀

define min(a,b) ((a) < (b) ? (a) : (b))

define max(a,b) ((a) > (b) ? (a) : (b))

💥 These macros clash with std::min and std::max:

std::min(a, b); // ← EXPANDS into macro chaos!

🔥 Why include guards won't save you:

If you #include <windows.h>, the curse is cast.

Header guards or #pragma once don’t help.

ImGui drags in windows.h via GLFW like an accidental summoning ritual.
Enter fullscreen mode Exit fullscreen mode

🧙‍♂️ The NOMINMAX Protective Incantation:

ifdef _WIN32

define NOMINMAX // ← Seals away the macro curse

endif

include // Safe now. Probably.

🧛‍♂️ Other Ancient Spells Still Lurking:

#define STRICT — Type safety incantation

#define WIN32_LEAN_AND_MEAN — Strips out bloated WinAPI

#define VC_EXTRALEAN — Even leaner. Less Windows, more sanity.
Enter fullscreen mode Exit fullscreen mode

🕳️ Yes, all of this still exists in Visual Studio 2022...

Because... compatibility with Win16 from 1995 still haunts us. 😭

Cross-platform libraries like ImGui are especially susceptible to this trap.

////////////////////////////////////////////////////////

✅ Claude Code finally managed to build successfully.
The ancient curse has been lifted... at least for now.

Top comments (2)

Collapse
 
dotallio profile image
Dotallio

Haha, felt every word of that ancient macro curse - I've hit that min/max wall so many times.
Curious, did building with Claude Code actually help you find these platform potholes faster?

Collapse
 
charmpic profile image
CharmPic

Thanks for the reply!
To be honest, Claude Code didn't spot the problem until we tried to build, but once the errors popped up, it went through and meticulously crushed every single one!