简体   繁体   English

我可以在 POSIX 线程中使用 C++ 类和 class 对象还调用 function 吗

[英]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.我想知道我可以在pthread.h的线程中使用 C++ 编程概念是否有任何限制,如果是,那会是什么。 any information about documentation of C++ in Posix threads I am looking for我正在寻找的 Posix 线程中有关 C++ 文档的任何信息

C++ was designed to interoperate with C, so you can use freely all the functions from the standard C library in C++. C++ 旨在与 C 互操作,因此您可以自由使用 C 库中的所有功能The only limitation is that the development has to be made in C++.唯一的限制是必须在 C++ 中进行开发。 C++ can use C functions with minor or no modification at all, but the reverse is not true: C can only use C functions. C++ can use C functions with minor or no modification at all, but the reverse is not true: C can only use C functions. In order to be able to include C++ code, you must first wrap the C++ code into为了能够包含 C++ 代码,您必须首先将 C++ 代码包装到

extern "C"

wrapper functions, and limit your use to only those functions inside, and link your program as a C++ program (this is necessary to initialize all the global instances that your program can have, calling the constructors appropiately before calling main() )包装函数,并将您的使用限制为仅内部的那些函数,并将您的程序链接为 C++ 程序(这是初始化程序可以拥有的所有全局实例所必需的,在调用main()之前适当地调用构造函数)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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