C/C ++, cc

Source: Internet
Author: User

C/C ++, cc

From: http://www.cnblogs.com/yc_sunniwell/archive/2010/07/14/1777431.html

1. Only declarations are made in the header file.

Global variable declaration:

Extern int var;

Global function declaration:

Void test (void );

2. Effect of extern

When extern is not modified with "C", for example, extern int g_Int in the header file, it is used to declare the keyword of the range of the function or global variable.

When extern is connected with "C", for example, extern "C" void fun (int a, int B ); the compiler will tell the compiler to translate the corresponding function name instead of the C ++ name according to the C rule when compiling the function name fun,

// In the. h file header # ifdef _ cplusplus # if _ cplusplusextern "C" {# endif/* _ cplusplus */...... // Where the. h file ends # ifdef _ cplusplus # if _ cplusplus} # endif/* _ cplusplus */

 

Related Article

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.