当前位置:网站首页>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 .
边栏推荐
- Should novice programmers memorize code?
- volatile关键字
- Self made j-flash burning tool -- QT calls jlinkarm DLL mode
- memcached
- 云原生技术--- 容器知识点
- Signed and unsigned keywords
- OpenNMS分离数据库
- [linear algebra] determinant of order 1.3 n
- That's why you can't understand recursion
- Balanced Multimodal Learning via On-the-fly Gradient Modulation(CVPR2022 oral)
猜你喜欢
基於 QEMUv8 搭建 OP-TEE 開發環境
Attack and defense world miscall
【编译原理】做了一半的LR(0)分析器
图像的spatial domain 和 frequency domain 图像压缩
Self made j-flash burning tool -- QT calls jlinkarm DLL mode
新手程序员该不该背代码?
Spatial domain and frequency domain image compression of images
3DMAX assign face map
Data processing skills (7): MATLAB reads the data in the text file TXT with mixed digital strings
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
【无标题】
go多样化定时任务通用实现与封装
软考高级(信息系统项目管理师)高频考点:项目质量管理
Leetcode: interview question 17.24 Maximum cumulative sum of submatrix (to be studied)
Volatile keyword
MySQL教程的天花板,收藏好,慢慢看
[线性代数] 1.3 n阶行列式
The nearest common ancestor of binary (search) tree ●●
CCNA Cisco network EIGRP protocol
i. Mx6ull build boa server details and some of the problems encountered
BasicVSR_PlusPlus-master测试视频、图片
void关键字
Learn the principle of database kernel from Oracle log parsing
基于 QEMUv8 搭建 OP-TEE 开发环境
Anaconda installs third-party packages
uniapp滑动到一定的高度后固定某个元素到顶部效果demo(整理)
Should novice programmers memorize code?
在IPv6中 链路本地地址的优势
SQL Server生成自增序号