gpt4 book ai didi

c++ - 为什么这个程序抛出 'std::system_error' ?

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:19:59 26 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Why does this simple std::thread example not work?

代码:

#include <iostream>
#include <thread>

void f()
{
std::cout << "hi thread" << std::endl;
}

int main()
{
std::thread t(f);
std::cout << "hi" << std::endl;
t.join();
}

问题:

$ g++ -o thread_test thread_test.cpp -std=c++0x
$ ./thread_test
terminate called after throwing an instance of 'std::system_error'
what(): Operation not permitted
Abortado

“Abortado”在我的语言环境中表示“中止”。

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com