Integration of C and C ++ in Linux

Source: Internet
Author: User
Integration of C and C ++ in Linux-general Linux technology-Linux programming and kernel information. For details, refer to the following section. Recently, we encountered a technical problem that was quite scratching our head. The code of our customer company in Boston was both C ++ and C. As an outsourcing company, we need to integrate our C ++ code with them. The original integration solution was that our C ++ was mixed with their C ++, in this way, I did not Touch any C integration winter. At that time, I had fixed this problem in Boston, but before the business trip back, the customer proposed to optimize the system efficiency, this means that we want to reuse their C code more, so that the tasks that integrate C and C ++ are gradually put on the agenda.

There are a lot of Chinese and English articles on the Internet discussing this aspect, but I don't feel very comprehensive. When I use these methods for some time, I don't provide a comprehensive and systematic solution to the problem, I picked one of them: Workshop

The first three parts are popular science. You can leave them alone. The last part describes the two examples of C ++ Calling C and C Calling C ++. They are very useful. Let me summarize:

(1) problems with C ++ Calling C:
In the File of C ++, add the header File of C. Generally, you need to add extern "C", but this is not an iron law. I will talk about this issue later, I think this is sometimes miserable. We recommend that you add the _ cplusplus macro to the original sample, for example:
QUOTE:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.