This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/49386] #undef min/max is dependent on order if #include
- From: "gintensubaru at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 13 Jun 2011 08:29:20 +0000
- Subject: [Bug libstdc++/49386] #undef min/max is dependent on order if #include
- Auto-submitted: auto-generated
- References: <bug-49386-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49386
--- Comment #4 from Takaya Saito <gintensubaru at gmail dot com> 2011-06-13 08:29:15 UTC ---
(In reply to comment #3)
> Ah yes. This is unfortunate, and I believe tricky to fix at the gcc end. We
> could in principle add '#undef min, #undef max', but I worry that might break
> something else.
>
> If you '#define NOMINMAX' before including windows.h, that should stop the
> declarations, although it can break some windows libraries. The other option is
> to do:
>
> #include <windows.h>
> #ifdef min
> #undef min
> #endif
> #ifdef max
> #undef max
> #endif
Well, this code:
// #include <iostream>
#define max( a, b ) bad_macro
#include <algorithm> // OK
does not raise errors, because there exist "#undef min" and "#undef max"
in file <bits/c++config>. So I think it should be a bug.