简体   繁体   中英

Error: 'thread' in namespace 'std' does not name a type

I have an error on my compile

错误图片

I tried to fix it by downloading and installing gcc-tdm, because a forum mentioned this is a compiler issue, but I am still getting the same result.

Does anyone know how to solve this?

Faced this issue just this morning. After reading up on it a bit, I realised I had MinGW with Win32 threads installed. A new clean install of MinGW with posix threads

https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/installer/mingw-w64-install.exe/download

and the issue gets resolved.

Link to original Win32 vs pthread post : mingw-w64 threads: posix vs win32

The version of GCC that CodeBlocks ships with doesn't support threads (or at least it was the case last time I checked). You'll have to install a better compiler, and configure CB to use it.

You can get a fresh version of GCC from MSYS2. Or you can install one of the numerous MinGW-w64 distributions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM