当前位置:网站首页>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 .
边栏推荐
- "Source code interpretation" famous programmer TJ's only library
- Win10 shortcut key
- Summary of STM32 serial port sending and receiving data methods
- Altium designer 19.1.18 - hide the fly line of a network
- Global and Chinese markets for recycled boilers 2022-2028: Research Report on technology, participants, trends, market size and share
- The folder directly enters CMD mode, with the same folder location
- Significance and requirements of semiconductor particle control
- Realization of binary relation of discrete mathematics with C language and its properties
- QT's excellent articles
- Day07 type of mathematical operator automatic conversion relational operator bitwise operator blind date math
猜你喜欢

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

Deepin get file (folder) list

Altium designer 19.1.18 - change the transparency of copper laying

How to migrate the device data accessed by the RTSP of the easycvr platform to easynvr?

Pagoda create multiple sites with one server

About the problem that MySQL connector net cannot be cleared in MySQL

Embedded AI intelligent technology liquid particle counter

Nombre - 1. Création de tableaux

Opendrive arc drawing script

What is Bezier curve? How to draw third-order Bezier curve with canvas?
随机推荐
MLPerf Training v2.0 榜单发布,在同等GPU配置下百度飞桨性能世界第一
Pointnet++ classification practice
Good websites need to be read carefully
Batch modify the txt file code to UTF-8 (notepad++)
Day07 type of mathematical operator automatic conversion relational operator bitwise operator blind date math
Apple terminal skills
Global and Chinese market of peeled bourdon tubes 2022-2028: Research Report on technology, participants, trends, market size and share
repo. conda. An example of COM path error
Count and sort the occurrence times of specific fields through SQL statements
Function and usage of function pointer
static的作用
assert_ Usage of param function
Let me teach you how to develop a graphic editor
如何将EasyCVR平台RTSP接入的设备数据迁移到EasyNVR中?
solver. Learning notes of prototxt file parameters
Process (P) runs, and idle is different from pycharm
TCP and UDP
High end electronic chips help upgrade traditional oil particle monitoring
Global and Chinese markets for flexible endoscopic lithotripsy devices 2022-2028: Research Report on technology, participants, trends, market size and share
"Source code interpretation" famous programmer TJ's only library