-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
std::min is broken if FMT_HEADER_ONLY is defined. #152
Comments
Thanks for the bug report. I couldn't find any reference to |
The problem is that windows.h will define min and max macros. |
you can just write int a = (std::min)(10, 20); and min max macros will not work and you don't need NOMINMAX |
This is a well-known problem with Windows headers and unfortunately I don't see a good way to address this without potentially breaking user code (which can happen if we unconditionally define
@DevO2012 Will it work for you? |
Yes I know that I can write (std::min)(10, 20) but only in my code not in other libraries that use std::min and std::max.
Can you please elaborate how this can break user code ?
Ok this seems to be the most safe solution :) |
It can happen if #include <format.h>
#include <windows.h> // can be included in another header, possibly C
max(1, 2); // same as above
I hope noone is using
Cool, I'm closing this issue then, but if you have any ideas on how to improve the situation feel free to reopen it. |
How about this solution ?
|
because they break std::min/max. This only affects non-default header-only configuration and can be disabled by defining FMT_WIN_MINMAX.
I've implemented something similar in 67ce394. Unfortunately it may still break if someone uses |
Solution is to put flowing lines just before windows include.
The text was updated successfully, but these errors were encountered: