Skip to content

Commit

Permalink
Avoid windows issue with min() max() macros
Browse files Browse the repository at this point in the history
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...
  • Loading branch information
gsjaardema authored and vitaut committed Apr 7, 2020
1 parent 27e3c0f commit 34b3f7b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion include/fmt/format-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@
#endif

#ifdef _WIN32
# if defined(NOMINMAX)
# include <windows.h>
# else
# define NOMINMAX
# include <windows.h>
# undef NOMINMAX
# endif
# include <io.h>
# include <windows.h>
#endif

#ifdef _MSC_VER
Expand Down

0 comments on commit 34b3f7b

Please sign in to comment.