Skip to content

Trouble compiling with gcc 11.1 #79

@MNRK01

Description

@MNRK01

Hi,

I have been trying to compile this code from boost 1.76.0 with mingw-w64 gcc 11:

/*  Copyright 2020 Rene Rivera
 *  Distributed under the Boost Software License, Version 1.0.
 *  (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
 */

/*
This program is a compile test for support of C++11. If it compiles
successfully some key parts of C++11 the B2 engine requires are
available. This is used by the build script to guess and check the
compiler to build the engine with.
*/

// Some headers we depend on..
#include <thread>


int main()
{
    // Check for basic thread calls.
    { auto _ = std::thread::hardware_concurrency(); }
}

I get the following error with gcc 11.1, but not with gcc 10.3 or other earlier gcc 10:

In file included from C:/mingw-gcc-11.1.0/i686-1110-win32-sjlj-rt_v9-rev0/mingw32/opt/include/mingw-std-threads/thread:3,
                 from check_cxx11.cpp:14:
C:/mingw-gcc-11.1.0/i686-1110-win32-sjlj-rt_v9-rev0/mingw32/opt/include/mingw-std-threads/mingw.thread.h:330:24: error: 'class mingw_stdthread::thread' conflicts with a previous declaration
  330 | using mingw_stdthread::thread;
      |                        ^~~~~~
In file included from C:/mingw-gcc-11.1.0/i686-1110-win32-sjlj-rt_v9-rev0/mingw32/lib/gcc/i686-w64-mingw32/11.1.0/include/c++/thread:43,
                 from C:/mingw-gcc-11.1.0/i686-1110-win32-sjlj-rt_v9-rev0/mingw32/opt/include/mingw-std-threads/thread:2,
                 from check_cxx11.cpp:14:
C:/mingw-gcc-11.1.0/i686-1110-win32-sjlj-rt_v9-rev0/mingw32/lib/gcc/i686-w64-mingw32/11.1.0/include/c++/bits/std_thread.h:62:9: note: previous declaration 'class std::thread'
   62 |   class thread
      |         ^~~~~~

It seems this error is new to gcc 11. Commenting out using mingw_stdthread::thread on line 330 of mingw.thread.h allows me to get past this error, but causes downstream errors when building boost as one can expect.

I'll say that I m surprised that it appears no one else has seen this issue with mingw-w64 gcc 11. I'm wondering if this is on my end. I build my own gcc with scripts from mingw-builds.

Thank you for making mingw-std-threads available and also for any help that you can provide on this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions