我是靠谱客的博主 狂野皮皮虾,最近开发中收集的这篇文章主要介绍Enable multithreading to use std::thread: Operation not permitted,觉得挺不错的,现在分享给大家,希望可以做个参考。
概述
简单示例
#include <iostream>
#include <thread>
void hello() {
std::cout << "hello world" << std::endl;
}
int main() {
std::thread t(hello);
t.join();
}
编译命令:
g++ -std=c++11 hello.cpp -o hello -pthread
C++支持多线程,有三点注意:
- 包含头文件
#include <thread>
- 编译选项
-std=c++11
- 编译选项
-pthread
不添加编译选项-pthread
,则运行出现Enable multithreading to use std::thread: Operation not permitted
。
选项中指定-lpthread
和-pthread
一样,建议使用-pthread
。
最后
以上就是狂野皮皮虾为你收集整理的Enable multithreading to use std::thread: Operation not permitted的全部内容,希望文章能够帮你解决Enable multithreading to use std::thread: Operation not permitted所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复