当前位置:网站首页>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 .
边栏推荐
- 【雅思口语】安娜口语学习记录part1
- Sword finger offer question brushing record 1
- Crawler obtains real estate data
- Daily question 1: force deduction: 225: realize stack with queue
- Volatile keyword
- C# 三种方式实现Socket数据接收
- Leetcode exercise - Sword finger offer 26 Substructure of tree
- Aardio - 不声明直接传float数值的方法
- go多样化定时任务通用实现与封装
- npm无法安装sharp
猜你喜欢

NPDP certification | how do product managers communicate across functions / teams?

RESNET rs: Google takes the lead in tuning RESNET, and its performance comprehensively surpasses efficientnet series | 2021 arXiv

HDR image reconstruction from a single exposure using deep CNN reading notes

Heavyweight news | softing fg-200 has obtained China 3C explosion-proof certification to provide safety assurance for customers' on-site testing

Leetcode exercise - Sword finger offer 26 Substructure of tree

Netxpert xg2 helps you solve the problem of "Cabling installation and maintenance"

第3章:类的加载过程(类的生命周期)详解

树的先序中序后序遍历

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

Export MySQL table data in pure mode
随机推荐
The nearest common ancestor of binary (search) tree ●●
【LeetCode】19、 删除链表的倒数第 N 个结点
Chapter 4: talk about class loader again
NetXpert XG2帮您解决“布线安装与维护”难题
Chapter 3: detailed explanation of class loading process (class life cycle)
【编译原理】做了一半的LR(0)分析器
小程序系统更新提示,并强制小程序重启并使用新版本
Sword finger offer question brushing record 1
Assembly and Interface Technology Experiment 6 - ADDA conversion experiment, AD acquisition system in interrupt mode
Puppeteer连接已有Chrome浏览器
Pit encountered by handwritten ABA
SQL Server生成自增序号
Advantages of link local address in IPv6
Sizeof keyword
MySQL----初识MySQL
LeetCode 练习——剑指 Offer 26. 树的子结构
变量与“零值”的比较
0 basic learning C language - digital tube
Aardio - 不声明直接传float数值的方法
signed、unsigned关键字