[libcxx] r194891 - Fix-it suggestion for fixing min or max defines on Windows.

Yaron Keren yaron.keren at gmail.com
Fri Nov 15 16:30:55 PST 2013


Hi Arthur,

Won't #undef max after including any MySQL header work as well?

Technically, the warning could be removed and max would be #undef quietly
and the defined as you suggest, but this is a design change so I refer this
to Howard.

Yaron



2013/11/16 Arthur O'Dwyer <arthur.j.odwyer at gmail.com>

> On Fri, Nov 15, 2013 at 3:41 PM, Yaron Keren <yaron.keren at gmail.com>
> wrote:
> >
> > -_LIBCPP_WARNING("macro min is incompatible with C++.  #undefing min")
> > +_LIBCPP_WARNING("macro min is incompatible with C++.  Try #define
> NOMINMAX "
> > +                "before any Windows header. #undefing min")
>
> Incidentally, this warning has annoyed me in the past when compiling
> MySQL 5.5 as C++. They have some code (in the name of portability, I'm
> sure) equivalent to
>
>     #ifndef max
>      #define min(a,b) (a < b ? a : b)
>      #define max(a,b) (a > b ? a : b)
>     #endif
>
> which I try to disable by putting
>
>     #define max max
>
> in another header. By #undef'ing max, libc++ interferes with this
> tactic — or rather, it's hard to tell for any given translation unit
> whether it interferes with it or not (depending on the order of
> #includes), which is even more distracting. I wonder whether it would
> be possible for the libc++ header to use
>
>     #undef max
>     #define max max
>
> instead of just "#undef max", or if the Standard prohibits that somehow.
>
> Not that I expect a change to happen, but I figured I should publicly
> register my particular use-case.
>
> –Arthur
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131116/58a1c51e/attachment.html>


More information about the cfe-commits mailing list