What problems could I get when defining NOMINMAX
before anything else in my program?
As far as I know, this will make <Windows.h>
not define the min
and max
macros such that many conflicts with the STL, e.g. std::min()
, std::max()
, or std::numeric_limits<T>::min()
are resolved.
Am I right in the assumption that only Windows-specific and legacy code will have problems?
Almost all libraries should not depend on min()
and max()
defined as macros?
Edit: Will there be be problems with other Windows headers?
NOMINMAX
works well. However, the library is also used by external developers and I do not want to break their applications.#define
is a compile-time operation. Libraries are linked in, not compiled in. This means they can have their own independent#define
s. Library users won't see that you#define
dNOMINMAX
NOMINMAX
. Still, you are right in that they could put their own code in a different compilation unit.