I expect this is expected to be defined from windows.h, but it isn't if you #define NOMINMAX which I have to on my project because of a different library. I suggest you just implement the macro yourself, something like this: #define safe_min(a, b) (((size_t)(a) < (size_t)(...