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

Arthur O'Dwyer arthur.j.odwyer at gmail.com
Fri Nov 15 16:47:11 PST 2013


On Fri, Nov 15, 2013 at 4:30 PM, Yaron Keren <yaron.keren at gmail.com> wrote:
> Hi Arthur,
>
> Won't #undef max after including any MySQL header work as well?

Yeah, but there are like 200 translation units involved, and I don't
want to audit all of them. Some of them might #include <algorithm>
before "my_global.h", some vice versa. Many won't #include either of
those headers, but will #include things that #include them... it's a
hard problem for a human to solve.

> 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.

Ideally libc++ would detect "#define max max" as a special "okay"
case, yet still give a warning (or better, an error) for "#define max
foo" in general. But I'm not sure there's any way to do that in the
preprocessor.

(And of course we shouldn't add any really arcane machinery just to
deal with one stupid legacy codebase. I agree that there's no good
excuse for #defining min or max in a modern C++ codebase.)

Thanks,
–Arthur




More information about the cfe-commits mailing list