The following is the test environment:
GCC 4.3.2-1-1
GNU/Linux Debian 5.0
(I have no experience using csdn blogs at the beginning. Due to the long debugging time in the middle, I forgot to back up the data. I just finished writing it and sent it quickly. A look, no; look again, still no. Get angry and rewrite an article. We hope that readers can back up data in a timely manner based on this recognition. :-)
1. extern and static
ExternUsage summary!
1. externThis function is often used in variable declarations *. the C file declares a global variable. If the global variable is to be referenced, it is placed in *. H and use extern to declare.
2. If the function declaration contains the keyword extern, it only implies that the function may be defined in other source files and has no other function. There is no difference between
How C ++ programmers explain the role of extern "C" to a java Engineer
Today, I am working on Android development. What is external "C?I said: To enable C ++ to compile classes or functions programmed in C language.
I guess he doesn't understand what I mean. Maybe I can't explain what this is.
IntroductionC ++ retains the features of some procedural languages, so it can define global variables and functions that do not belong to any class. However, C
1: #ifndef __INCvxWorksh
2: #define __INCvxWorksh
3: #ifdef __cplusplus
4: extern "C" {
5: #endif
6: /*...*/
7: #ifdef __cplusplus
8: }
9: #endif
10: #endif /* __INCvxWorksh */
Obviously, the compilation macro "# ifndef _ incvxworksh, # DEFINE _ incvxworksh, and # endif" in the header file is used to prevent the header file from being repeatedly referenced.
What is the role of 3-9 lines of code?
1: Meaning of
The extern declaration variable is no different from the following two kinds:
1. Declaring Global variables2. Declaring functions
Today we only talk about extern, what const, static and so on and so on and related or unrelated to all ignore, the following on the above two kinds of situation to explain each
Declarations and definitionsNow that we're talking about exte
file contains
——————————————————————————————————————Symbolic meaning——————————————————————————————————————Static 1. Inside a function, the value of the variable is persisted between invocations2. At the level of the function, it means that the function is visible only to this text——————————————————————————————————————extern 1 for function definitions, representing global visibility (redundant, default globally visible)2. For variables, indicating that
Text: Understanding the keyword extern in the C language
Recently wrote a C program, compile the variable duplicate definition of the error, you see no errors found. Using Google found that the extern understanding is not thorough, I searched this article, written well. I made a poor translation. (Original: http://www.geeksforgeeks.org/understanding-extern
C language extern keyword
Extern, Which is external or external. So what does it do? For example, suppose you see a black-skinned, green-eyed, and redheaded beauty on the street (Aliens ?) Or handsome guy. Your first reaction is that this person is not made in China. Extern is equivalent to these characteristics that distinguish them from the Chinese.
macro "# ifndef _ incvxworksh, # DEFINE _ incvxworksh, and # endif" in the header file is used to prevent the header file from being repeatedly referenced.
So
# Ifdef _ cplusplusExtern "C "{# Endif# Ifdef _ cplusplus}# Endif
What is the role? We will discuss it one by one below.3. Deep encryption extern "C"
Extern "C" contains a double meaning, which can be obtained literally: first, the target is "
_ cplusplus}# Endif# Endif/* _ incvxworksh */
Analysis
Obviously, the compilation macro "# ifndef _ incvxworksh, # DEFINE _ incvxworksh, and # endif" in the header file is used to prevent the header file from being repeatedly referenced.
So
# Ifdef _ cplusplusExtern "C "{# Endif# Ifdef _ cplusplus}# Endif
What is the role? We will discuss it one by one below.
3. Deep encryption extern "C"
Extern "C" cont
* *
AnalysisObviously, the role of the compiled macro "#ifndef __incvxworksh, #define __incvxworksh, #endif" In the header file is to prevent the header file from being repeatedly referenced.So
#ifdef __cplusplusextern "C" {#endif#ifdef __cplusplus}#endif
What is the role of it. We will come in the following one by one ways.
3. Deep disclosure of extern "C"
The extern "C" contains
"{# Endif# Ifdef_ Cplusplus}# Endif
What is the role? We will discuss it one by one below.3. Deep encryption extern "C"
Extern "C"It contains double meanings, which can be obtained literally: first, the target to be modified is "extern", and second, the target to be modified is "C. Let's explain these two meanings in detail.
The function or variable specified by
_ incvxworksh, and # endif" in the header file is used to prevent the header file from being repeatedly referenced. So
# Ifdef _ cplusplusExtern "C "{# Endif# Ifdef _ cplusplus}# Endif
What is the role? We will discuss it one by one below.
3. Deep encryption extern "C"
Extern "C" contains a double meaning, which can be obtained literally: first, the target is "extern
This code is often seen in the CPP code:
#ifdef __cplusplusextern "C" {#endif//一段代码#ifdef __cplusplus}#endif
What exactly does this code mean? First of all, __cplusplus is a custom macro in CPP, then the definition of the macro means that this is a CPP code, that is, the above code means: If this is a section of CPP code, then add extern "C" {and} to process the code.
To understand why extern "C" is us
One, extern and function
Second, static and function
Iii. Summary of static, extern and function
Description: This C language topic is the prelude to learning iOS development. And for programmers with an object-oriented language development experience, you can quickly get started with C language. If you don't have programming experience, or are not interested in C or iOS d
The attributes of variables and functions include the data type and data storage class. The storage class index data is stored in memory (static and dynamic), including auto, static, register, and extern.
Memory. Specifically, memory is divided into three parts: static zone, heap zone, and stack zone. External variables and global variables are stored in the static zone, local variables are stored in the stack zone, and the dynamically opened memory
First the extern keyword:extern is a keyword that indicates the scope (visibility) of functions and global variables in the C/s + + language, which tells the compiler that its declared functions and variables can be used in this module or in other modules.Typically, the function and global variables that this module provides to other modules in the header file of the module are declared with the keyword extern
Knowledge Points:External functions: Defined functions can be accessed by this file and other files1> all functions are external functions by default2> external functions with the same name are not allowedIntrinsic functions: Defined functions can only be accessed by this file and other files cannot be accessed1> allows internal functions with the same name in different filesStatic effects on functions:1> defines an intrinsic function2> declares an intrinsic functionThe effect of
1 Basic explanations
extern can be placed before a variable or function to mark 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.
In addition, extern can also be used for link designation.
2 Question: extern variable
An array is defined in a so
1 Basic explanations
extern can be placed before a variable or function to mark 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.
In addition, extern can also be used for link designation.
2 Question: extern variable
An array is defined in a s
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.