HowardHinnant / date

A date and time library based on the C++11/14/17 <chrono> header
Other
3.14k stars 675 forks source link

Not enough arguments for function-like macro invocation 'min' #796

Open peakpeak-github opened 1 year ago

peakpeak-github commented 1 year ago

Windows 10, Visual Studio 2022 set to C++17, error when including date.h date.h(419,27): warning C4003: not enough arguments for function-like macro invocation 'min': static CONSTCD11 year min() NOEXCEPT { return year{-32767}; }

Visual Studio claims min() is defined in minwindef.h:

ifndef min

define min(a,b) (((a) < (b)) ? (a) : (b))

endif

The .cpp file starts like this:

include

include "date\date.h"

How can I resolve this?

HowardHinnant commented 1 year ago

#define NOMINMAX just prior to including Windows headers to inhibit this behavior. There's a place in the MS IDE somewhere for such macros.

peakpeak-github commented 1 year ago

Thanks! That worked!