当前位置:网站首页>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 .
边栏推荐
- 3DMAX assign face map
- UE4蓝图学习篇(四)--流程控制ForLoop和WhileLoop
- AdaViT——自适应选择计算结构的动态网络
- Anaconda installs third-party packages
- Aardio - 利用customPlus库+plus构造一个多按钮组件
- Report on technological progress and development prospects of solid oxide fuel cells in China (2022 Edition)
- 第3章:类的加载过程(类的生命周期)详解
- Spatial domain and frequency domain image compression of images
- 软考高级(信息系统项目管理师)高频考点:项目质量管理
- Daily question 1: force deduction: 225: realize stack with queue
猜你喜欢

【编译原理】做了一半的LR(0)分析器

剪映+json解析将视频中的声音转换成文本
![pytorch_ Yolox pruning [with code]](/img/98/31d6258635ce48ac53819d0ca12d1d.jpg)
pytorch_ Yolox pruning [with code]

Assembly and Interface Technology Experiment 6 - ADDA conversion experiment, AD acquisition system in interrupt mode

Aardio - 封装库时批量处理属性与回调函数的方法

CocosCreator+TypeScripts自己写一个对象池

二分图判定

(18) LCD1602 experiment

在IPv6中 链路本地地址的优势

Daily question 1: force deduction: 225: realize stack with queue
随机推荐
BasicVSR_PlusPlus-master测试视频、图片
Aardio - 通过变量名将变量值整合到一串文本中
Sizeof keyword
Attack and defense world ditf Misc
Balanced Multimodal Learning via On-the-fly Gradient Modulation(CVPR2022 oral)
Aardio - 不声明直接传float数值的方法
Dealing with the crash of QT quick project in offscreen mode
return 关键字
Gd32f4xx serial port receive interrupt and idle interrupt configuration
pytorch_ Yolox pruning [with code]
Management background --5, sub classification
C# 三种方式实现Socket数据接收
2022-07-05 stonedb的子查询处理解析耗时分析
Signed and unsigned keywords
RESNET rs: Google takes the lead in tuning RESNET, and its performance comprehensively surpasses efficientnet series | 2021 arXiv
ThreadLocal详解
(18) LCD1602 experiment
sizeof关键字
硬件開發筆記(十): 硬件開發基本流程,制作一個USB轉RS232的模塊(九):創建CH340G/MAX232封裝庫sop-16並關聯原理圖元器件
硬件开发笔记(十): 硬件开发基本流程,制作一个USB转RS232的模块(九):创建CH340G/MAX232封装库sop-16并关联原理图元器件