c++ - Can I use C++ classes and class objects inside POSIX thread also function calls
问题描述
I like to know can I use C++ programming concepts in threads from pthread.h
is there any limitation, if yes then what would that be. any information about documentation of C++ in Posix threads I am looking for
解决方案
C++ 旨在与 C 互操作,因此您可以在 C++ 中自由使用标准 C 库中的所有函数。唯一的限制是必须使用 C++ 进行开发。C++ 可以使用稍加修改或根本不修改的 C 函数,但反之则不然:C 只能使用 C 函数。为了能够包含 C++ 代码,您必须首先将 C++ 代码包装到
extern "C"
包装函数,并将您的使用限制为仅内部的那些函数,并将您的程序链接为 C++ 程序(这是初始化程序可以拥有的所有全局实例所必需的,在调用之前适当地调用构造函数main()
)
推荐阅读
- python - Python 和抓取数据。获取没有链接的特定选项卡并浏览多个页面
- javascript - 从 Google Playground 获取访问令牌以测试项目
- julia - 如何将 julia 文件支持添加到 Jupyterlab 编辑器?
- jquery - 在jquery中获取选中复选框的值和图像
- typescript - import * as util from "./util" vs import {someFunction} from "./util"
- firefox - Firefox Web 扩展的上下文菜单项的图标可以即时更改吗?
- haskell - 尝试在 Haskell 中为函数指定类型时,出现“使用 `print' 导致没有 (Show (Int -> Int)) 的实例”错误的原因是什么?
- php - 如何在 laravel 中以生产模式下载文件
- php - laravel 选择的学位id无效
- ms-access - 使用表中列的值填写报告复选框