当前位置:网站首页>Extern keyword function
Extern keyword function
2022-07-05 07:51:00 【Yang_ Winston】
grammar
extern Before variables and function declarations , Indicates that the variable or function has been defined in other files , Prompt the compiler to look for other files when compiling . besides ,extern It can also be used to specify links .
effect
- Declare external variables
When declaring global variables , Different files are opaque when compiled by the compiler , For example A.c In the definition of int i, At the same time B.c In the definition of int i, The compiler will not report errors when compiling , But when links linking It will report an error and repeat the definition . When you need to use the same global variable , Such as : stay A.c It defines int i, stay B.c You need to call i, Only need B.c In a statement extern int i, Indicates that the variable has been defined in other files , There will be no errors when compiling , stay linking… It will automatically find the defined variables i. - extern Function declaration
extern void fun() It implies that this function may have been defined in other files , It and are defined as void fun(), No difference , It is useful for complex projects by adding extern Declaration to substitute include" *.h" To declare functions . - Unilaterally modify the function prototype
When declared extern void fun(int i,int j,int k) when , In the subsequent calls, if you press yes fun(x,y,z) There is no problem when calling the prototype of , But if you want to modify the function, such as input parameters , When called fun(x,y) At this point, the compiler will report an error , The solution is to get rid of extern, Declared in the header file void fun(int i,int j), And modify the function , Then include the header file of the function in the called file " *.h" that will do .
边栏推荐
- Oracle-触发器和程序包
- Global and Chinese markets for flexible endoscopic lithotripsy devices 2022-2028: Research Report on technology, participants, trends, market size and share
- Numpy——1.数组的创建
- mysql 盲注常见函数
- Butterfly theme beautification - Page frosted glass effect
- Global and Chinese market of resistivity meter 2022-2028: Research Report on technology, participants, trends, market size and share
- Pit record of Chmod 2 options in deepin
- Apple modify system shortcut key
- High end electronic chips help upgrade traditional oil particle monitoring
- 研究發現,跨境電商客服系統都有這五點功能!
猜你喜欢

Differences between pycharm and idle and process -- join() in vs Code

Deepin get file (folder) list

MySQL - storage engine

What is Bezier curve? How to draw third-order Bezier curve with canvas?

Oracle-触发器和程序包

Logistic regression: the most basic neural network

Package ‘*****‘ has no installation candidate

Could NOT find XXX (missing: XXX_LIBRARY XXX_DIR)

Realization of binary relation of discrete mathematics with C language and its properties

Numpy——1.数组的创建
随机推荐
找不到实时聊天软件?给你推荐电商企业都在用的!
STM32 learning method
Openxlsx field reading problem
II Simple NSIS installation package
How to excavate and research ideas from the paper
Thunderbird tutorial \ easy to use mail client
MySQL - storage engine
1089 insert or merge, including test point 5
static的作用
Numpy——1.数组的创建
Mouse click fireworks explosion effect
The printer encountered an abnormal configuration problem 0x8007007e (win10)
A simple method to prove 1/t Fourier transform
Oracle-触发器和程序包
软件设计师:03-数据库系统
Global and Chinese markets for recycled boilers 2022-2028: Research Report on technology, participants, trends, market size and share
Mlperf training v2.0 list released, with the same GPU configuration, the performance of Baidu PaddlePaddle ranks first in the world
Detailed explanation of C language pointer
Use of orbbec Astra depth camera of OBI Zhongguang in ROS melody
The browser cannot access Baidu