C language and C + + basic knowledge point (Must SEE) _c language

Source: Internet
Author: User

1, suffix name: C++/c program header file with. h as the suffix, c program source file with. C as the suffix, C + + program source files are usually suffix. cpp (some books introduce some systems with a. cc or. cxx as a suffix of source files).
In the Linux system, GCC,. C (partial),. cc OR. cxx the source file for the suffix,

They are also C + + source code files.

2.extern keyword: extern can be placed before a variable or function to indicate the definition of a variable or function in another file, prompting the compiler to find its definition in other modules when it encounters this variable and function. Additionally, extern can be used for link designation.

Which means that extern has two functions, the first one, when it is used with "C", such as: extern "C" void fun (int a, int b), tells the compiler to compile fun this function name, according to the rules of C to translate the corresponding function name rather than C + +, C + + In translating this function name, the fun name will become unrecognizable, possibly

fun@abc_int_int#%$ may also be something else, depending on the "temper" of the compiler (different compilers use the same method)

Second, when extern does not modify a variable or function together with "C", as in a header file: extern int g_int; Its role is to declare the function or global variables of the scope of the keyword, its declared functions and variables can be used in this module live other modules, remember it is a declaration is not defined! That is, if the B module (the compilation unit) refers to a global variable or function defined in the module (compile unit) A, It only contains the header file of a module, in the Compile phase, Module B can not find the function or variable, but it will not error, it will be in the connection from module a generated from the target code to find this function.

The above C language and C + + basic knowledge point (Must SEE) is small to share all the content of everyone, hope to give you a reference, but also hope that we support cloud habitat community.

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.