C&c++--extern

Source: Internet
Author: User


1.C calling a C + + function or variable
C calls C + + functions or variables, the header file in C + + is declared as extern "C", and C is called using only the extern declaration.
As can be seen, extern "C" tells the C + + compiler to use the C link rule to generate and find the symbol name in the target file.
In short, the extern "C" {}, declared in C + +, tells the compiler to generate (or look for) the target symbol in the way that the function or variable declared in {} uses C.


3. C + + calls inline function
When a function in C is declared as an inline function using __inline, it does not link to the target symbol.
The function in EXAMPLE_C.C is changed to __inline void Print_c (int i) and the print_c symbol is not found in example_c.obj.
You can use a declaration such as __declspec (dllexport) __inline void print_c (int i) to generate the target symbol External | _print_c.

C&c++--extern

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.