Relationship between 5.7c and C ++

Source: Internet
Author: User

Interview Example 1: In the C ++ program, why should I add the extern "C" to call the function compiled by the C compiler "?

A: function Overloading is supported in C ++ and function Overloading is not supported in C. The name of the function in the library after being compiled by C ++ is different from that in C language. Assume that the prototype of a function is void Foo (int x, int Y ). after the function is compiled by the C compiler, its name in the library is _ Foo, while the C ++ compiler generates names such as _ foo_int_int.

C ++ provides the C-link exchange and formulation symbol extern "C" to solve the name matching problem.

Interview Example 2:How can I determine whether a program is compiled by C or C ++?

C ++ defines _ cplusplus during compilation.

C defines _ stdc during compilation.

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.