当前位置:网站首页>Extern keyword
Extern keyword
2022-07-06 22:31:00 【It's Beichen not too PI acridine】
1.extern Can be placed in front of variables or functions , A function defined in a file or other variable , The variables or functions used in the following code are foreign , Not defined in this document , Prompt the compiler to look for its definition in other modules when it encounters this variable and function . It's like putting a hat on these foreign variables or functions in this document , Tell all the codes in this document , These guys are not indigenous .
C Language policy , If you omit extern, The default is external function .
extern Whether the modified variable or function is defined or declared ?
answer : It is a statement.
A.c The document defines :
int i = 10;
void fun(void)
{
//code
}
B.c Used in documents extern modification :
extern int i;
extern void fun(void);
2. as for extern“C” Usage of , It is generally believed to belong to C++ The category of , Let's not discuss it here .
extern "C" The main function of is to realize C++ Code calls other C The language code . add extern "C" after , Will instruct the compiler to press C Compiling of language , instead of C++ Of . because C++ Support function overload , Therefore, the compiler will add the function's parameter type to the compiled code when compiling the function , Not just function names ; and C Language does not support function overloading , So compile C The function of language code will not take the parameter type of function , In general, it includes function names .
This function is very useful , Because in C++ Before appearance , A lot of code is C Written language , And the bottom library is also C Written language , In order to better support the original C Code and what's written C Language library , Need to be in C++ Support as much as possible in C, and extern "C" One of the strategies .
边栏推荐
- Plafond du tutoriel MySQL, bien collecté, regardez lentement
- 剑指offer刷题记录1
- 将MySQL的表数据纯净方式导出
- 【踩坑合辑】Attempting to deserialize object on CUDA device+buff/cache占用过高+pad_sequence
- config:invalid signature 解决办法和问题排查详解
- China 1,4-cyclohexanedimethanol (CHDM) industry research and investment decision-making report (2022 Edition)
- Improving Multimodal Accuracy Through Modality Pre-training and Attention
- Aardio - 通过变量名将变量值整合到一串文本中
- 【无标题】
- Data processing skills (7): MATLAB reads the data in the text file TXT with mixed digital strings
猜你喜欢

Balanced Multimodal Learning via On-the-fly Gradient Modulation(CVPR2022 oral)

Seata aggregates at, TCC, Saga and XA transaction modes to create a one-stop distributed transaction solution

NetXpert XG2帮您解决“布线安装与维护”难题

Advantages of link local address in IPv6

Leetcode exercise - Sword finger offer 26 Substructure of tree

That's why you can't understand recursion
![[linear algebra] determinant of order 1.3 n](/img/6e/54f3a994fc4c2c10c1036bee6715e8.gif)
[linear algebra] determinant of order 1.3 n

关于声子和热输运计算中BORN电荷和non-analytic修正的问题

NPDP certification | how do product managers communicate across functions / teams?
![pytorch_ Yolox pruning [with code]](/img/98/31d6258635ce48ac53819d0ca12d1d.jpg)
pytorch_ Yolox pruning [with code]
随机推荐
关于声子和热输运计算中BORN电荷和non-analytic修正的问题
poj 1094 Sorting It All Out (拓扑排序)
Attack and defense world ditf Misc
BasicVSR_PlusPlus-master测试视频、图片
go多样化定时任务通用实现与封装
RESNET rs: Google takes the lead in tuning RESNET, and its performance comprehensively surpasses efficientnet series | 2021 arXiv
【无标题】
[线性代数] 1.3 n阶行列式
图像的spatial domain 和 frequency domain 图像压缩
UDP programming
Applet system update prompt, and force the applet to restart and use the new version
The nearest common ancestor of binary (search) tree ●●
Sword finger offer question brushing record 1
(18) LCD1602 experiment
Senior soft test (Information System Project Manager) high frequency test site: project quality management
Comparison between variable and "zero value"
[IELTS speaking] Anna's oral learning record part1
What are the interface tests? What are the general test points?
0 basic learning C language - interrupt
12、 Start process