-
Notifications
You must be signed in to change notification settings - Fork 37
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
min/max compilation issues with MSVC #68
Comments
The easiest fix is tell people to #define NOMINMAX before including windows.h, or include Dragonbox before windows.h. But that's kinda impolite, so I agree with doing something.
Personally I'd go for push_macro, to keep the msvc ugliness localized and not spread throughout the codebase, but your choice. |
I wouldn't tell users to |
@stephenberry @Alcaro Thanks for the suggestions. My initial thought when I first wrote it was that "well, any sane developer should do
The After a search, it seems actually GCC also supports it for compatibility with MSVC (and probably Clang as well), but I would just get my hands dirty with the parenthesis trick rather than relying on a language extension without a fallback. PR is very much welcome, or I'll do it myself later if I have time. Thanks again! |
MSVC windows headers define macros for
min
andmax
, which conflict with any use ofmin
andmax
names in code, like dragonbox. An elegant solution is to add parenthesis, for example changestd::max(a, b)
to(std::max)(a, b)
, this prevents macro expansion and doesn't change the logic of the code.The text was updated successfully, but these errors were encountered: