mingw 5 std::this_thread ไม่ได้ถูกกำหนดไว้

สวัสดี มีใครลองใช้การรองรับส่วนหัว mingw w64 บ้างไหม?

main.cpp: In function 'int main()':
main.cpp:9:10: error: 'std::this_thread' has not been declared
std::this_thread::sleep_for( dura );
      ^

ฉันได้รับข้อผิดพลาดข้างต้นด้วยการทดสอบง่ายๆ ต่อไปนี้

#include <iostream>
#include <chrono> 
#include <thread>

int main()
{ 
 std::cout << "Hello waiter" << std::endl;
 std::chrono::milliseconds dura( 2000 );
 std::this_thread::sleep_for( dura );
 std::cout << "Waited 2000 ms\n";
}

ฉันต้องการใช้ N3653 และ N3651 ล่าสุดตามที่ระบุไว้ที่นี่ https://gcc.gnu.org/projects/cxx1y.html และแน่นอนว่ารองรับเธรดส่วนหัว โดยใช้บิวด์บางอย่างที่พบได้ที่นี่ http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/dongsheng-daily/5.0/ และ c++config.h _GLIBCXX_USE_NANOSLEEP ของฉันไม่ได้ถูกกำหนดไว้ มีความคิดใดบ้าง

[แก้ไข] ฉันรู้ว่าโมเดลเธรดของฉันคือ: win32 และไม่ใช่ posix หนึ่ง จะเปิดใช้งานการสนับสนุน posix ได้อย่างไร?


person user3453753    schedule 24.02.2015    source แหล่งที่มา
comment
ความคิดเห็นไม่ได้มีไว้สำหรับการอภิปรายเพิ่มเติม บทสนทนานี้ ย้ายไปยังแชทแล้ว< /ก>.   -  person George Stocker    schedule 26.02.2015


คำตอบ (1)


คุณสามารถใช้ update-alternatives สำหรับ i686-w64-mingw-g++ และตั้งค่าเป็น i686-w64-mingw-g++-posix จาก i686-w64-mingw-g++-win32

หรือคุณสามารถใช้ i686-w64-mingw-g++-posix เพื่อคอมไพล์ มีเวอร์ชันอื่นๆ อยู่ด้วย ดังนั้นในกรณีนี้ คุณจะต้องใช้คอมไพเลอร์ 64 บิตแทนและเติม -posix ต่อท้าย

person haelmic    schedule 21.05.2019