当前位置:网站首页>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 .
边栏推荐
- Deepin get file (folder) list
- Day06 class variables instance variables local variables constant variables naming conventions
- II Simple NSIS installation package
- High end electronic chips help upgrade traditional oil particle monitoring
- Train your dataset with yolov4
- Global and Chinese markets for waste treatment air switches 2022-2028: Research Report on technology, participants, trends, market size and share
- Numpy——1. Creation of array
- Global and Chinese markets for anesthesia, breathing and sleep apnea devices 2022-2028: Research Report on technology, participants, trends, market size and share
- PIL's image tool image reduction and splicing.
- Opendrive arc drawing script
猜你喜欢
Close of office 365 reading
MLPerf Training v2.0 榜单发布,在同等GPU配置下百度飞桨性能世界第一
MySQL blind note common functions
SQL JOINS
MySql——存储引擎
万字详解八大排序 必读(代码+动图演示)
Numpy——1. Creation of array
研究發現,跨境電商客服系統都有這五點功能!
The research found that the cross-border e-commerce customer service system has these five functions!
The printer encountered an abnormal configuration problem 0x8007007e (win10)
随机推荐
The browser cannot access Baidu
STM32 learning method
[popular science] some interesting things that I don't know whether they are useful or not
Altium designer 19.1.18 - hide the fly line of a network
The global and Chinese market of lithographic labels 2022-2028: Research Report on technology, participants, trends, market size and share
The sublime version that XP can run is 3114
How to excavate and research ideas from the paper
Global and Chinese market of quenching furnaces 2022-2028: Research Report on technology, participants, trends, market size and share
Day08 ternary operator extension operator character connector symbol priority
repo. conda. An example of COM path error
Altium Designer 19.1.18 - 隐藏某一个网络的飞线
Acwing - the collection of pet elves - (multidimensional 01 Backpack + positive and reverse order + two forms of DP for the answer)
String alignment method, self use, synthesis, newrlcjust
Threads and processes
[professional literacy] core conferences and periodicals in the field of integrated circuits
A simple method to prove 1/t Fourier transform
Global and Chinese market of plastic recycling machines 2022-2028: Research Report on technology, participants, trends, market size and share
Thunderbird tutorial \ easy to use mail client
Extended application of single chip microcomputer-06 independent key
Application of ultra pure water particle counter in electronic semiconductors