Mingw-packages: GCC fails if <windows.h> is included before <string>

Created on 14 May 2017  路  7Comments  路  Source: msys2/MINGW-packages

Is this a new bug introduced between mingw-w64-x86_64-gcc-6.2.0-2 and mingw-w64-x86_64-gcc-6.3.0-2 or am I just doing something stupid?

When compiling the following

#include<windows.h>
#include<string>

int main(int argc, char *argv[]){
   return 0;
}

I get very ugly errors from gcc (see attached).
If I change the inclusion order of #include<windows.h> and #include<string> the problem is solved.

error2.txt

Most helpful comment

Problem confirmed fixed (or at least worked around) by 9fbabc02488c69d4ac338de3b615057947912874 and the binary release of gcc version 6.3.0-3.

@Alexpux and @DavidEGrayson: Thanks for the quick reaction time! Are there already plans for a real fix at this time that does not require to patch almost 3000 lines in libstdc++?

All 7 comments

In short there is a conflict between mingw-w64 and libstdc++ __in and __out after https://gitlab.com/mati865/mingw-w64-mirror/commit/b7f44b677f43c3bb5f771ff5a430206de040c48c

As workaround downgrade mingw-w64-crt and mingw-w64-headers.

I confirm I am also affected by this bug. As a work around, I added:

#undef __in
#undef __out

at the end of windows.h.

I am experiencing the same thing

Should be fixed with updated GCC package (available in binary repo).

Already testing...

Problem confirmed fixed (or at least worked around) by 9fbabc02488c69d4ac338de3b615057947912874 and the binary release of gcc version 6.3.0-3.

@Alexpux and @DavidEGrayson: Thanks for the quick reaction time! Are there already plans for a real fix at this time that does not require to patch almost 3000 lines in libstdc++?

As i understand, this _is_ the real fix, which is wished to be merged upstream.

Was this page helpful?
0 / 5 - 0 ratings