Skip to content
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

Avoid windows issue with min() max() macros #1616

Merged
merged 1 commit into from
Apr 7, 2020

Conversation

gsjaardema
Copy link
Contributor

Including the windows.h file without defining NOMINMAX will define the min() and max() macros which will result in issues compiling any C++ code that uses any variant of max, for example std::numeric_limits<std::streamsize>::max() and many others. Although max() isn't used in Fmt anywhere, it is often used in codes that include a format include file so simply upgrading to the current version of lib::fmt will break the windows build which worked prior to the update...

The fix here is pulled from the 6.1.2 release.

I agree that my contributions are licensed under the {fmt} license, and agree to future changes to the licensing.

Including the ``windows.h`` file without defining ``NOMINMAX`` will define the `min()` and `max()` macros which will result in issues compiling any C++ code that uses any variant of `max`, for example `std::numeric_limits<std::streamsize>::max()` and many others.  Although max() isn't used in Fmt anywhere, it is often used in codes that include a format include file so simply upgrading to the current version of lib::fmt will break the windows build which worked prior to the update...
@vitaut
Copy link
Contributor

vitaut commented Apr 7, 2020

Thanks for the PR. fmt/format-inl.h is an internal header so it shouldn't affect users unless they opt into the header-only mode.

@gsjaardema
Copy link
Contributor Author

Yes, we use the header-only mode and our code started failing the windows build right after the update to 6.2.0 with no other changes. Not something that we expected; also not something that is easy to protect in our code since difficult to tell when we include a fmt include file whether it will be including fmt/format-inl.h

@vitaut vitaut merged commit 34b3f7b into fmtlib:master Apr 7, 2020
@gsjaardema gsjaardema deleted the patch-6 branch April 7, 2020 15:41
@gsjaardema
Copy link
Contributor Author

Thanks. Great library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants