当前位置:网站首页>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 .
边栏推荐
- Global and Chinese markets of large aperture scintillators 2022-2028: Research Report on technology, participants, trends, market size and share
- A series of problems in offline installation of automated test environment (ride)
- Leetcode solution - number of islands
- Distinction between heap and stack
- Count and sort the occurrence times of specific fields through SQL statements
- Global and Chinese market for blood typing 2022-2028: Research Report on technology, participants, trends, market size and share
- What is Bezier curve? How to draw third-order Bezier curve with canvas?
- Embedded AI intelligent technology liquid particle counter
- Cygwin installation
- repo. conda. An example of COM path error
猜你喜欢
Latex notes
Leetcode solution - number of islands
Thunderbird tutorial \ easy to use mail client
Significance and requirements of semiconductor particle control
What is Bezier curve? How to draw third-order Bezier curve with canvas?
Embedded AI intelligent technology liquid particle counter
MySQL - storage engine
The folder directly enters CMD mode, with the same folder location
Altium designer 19.1.18 - Import frame
Win10 shortcut key
随机推荐
Altium Designer 19.1.18 - 更改铺铜的透明度
Apple animation optimization
[professional literacy] core conferences and periodicals in the field of integrated circuits
Day01 markdown log entry tips
研究發現,跨境電商客服系統都有這五點功能!
. Net service governance flow limiting middleware -fireflysoft RateLimit
Explain STM32 startup file in detail
Altium Designer 19.1.18 - 隐藏某一个网络的飞线
STM32 learning method
Deepin, help ('command ') output saved to file
String judgment
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)
Train your dataset with yolov4
Use stm32cubemx tool to write the demo program of FreeRTOS
Latex notes
Apple system shortcut key usage
Logistic regression: the most basic neural network
Global and Chinese market of blackbody calibration source 2022-2028: Research Report on technology, participants, trends, market size and share
Apple input method optimization