当前位置:网站首页>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 .
边栏推荐
- Altium designer 19.1.18 - hide the fly line of a network
- "Source code interpretation" famous programmer TJ's only library
- [popular science] some interesting things that I don't know whether they are useful or not
- Global and Chinese markets for recycled boilers 2022-2028: Research Report on technology, participants, trends, market size and share
- Explain STM32 startup file in detail
- Detour of Tkinter picture scaling
- 研究发现,跨境电商客服系统都有这五点功能!
- Summary of STM32 serial port sending and receiving data methods
- Global and Chinese market of quenching furnaces 2022-2028: Research Report on technology, participants, trends, market size and share
- Nombre - 1. Création de tableaux
猜你喜欢
MySQL blind note common functions
Realization of binary relation of discrete mathematics with C language and its properties
Embedded AI intelligent technology liquid particle counter
A simple method to prove 1/t Fourier transform
Practical application cases of digital Twins - fans
数字孪生实际应用案例-风机篇
Altium designer 19.1.18 - change the transparency of copper laying
Numpy——1.數組的創建
Logistic regression: the most basic neural network
L'étude a révélé que le système de service à la clientèle du commerce électronique transfrontalier a ces cinq fonctions!
随机推荐
Train your dataset with yolov4
Butterfly theme beautification - Page frosted glass effect
Package ‘*****‘ has no installation candidate
Global and Chinese market of rammers 2022-2028: Research Report on technology, participants, trends, market size and share
[neo4j] common operations of neo4j cypher and py2neo
Calibre garbled
Opendrive arc drawing script
[professional literacy] core conferences and periodicals in the field of integrated circuits
Altium Designer 19.1.18 - 隐藏某一个网络的飞线
Use of orbbec Astra depth camera of OBI Zhongguang in ROS melody
Altium designer 19.1.18 - hide the fly line of a network
Random function usage notes
如何将EasyCVR平台RTSP接入的设备数据迁移到EasyNVR中?
Markdown tips
Global and Chinese market for blood typing 2022-2028: Research Report on technology, participants, trends, market size and share
mysql 盲注常见函数
C language uses arrays to realize the intersection, union, difference and complement of sets
Global and Chinese markets for flexible endoscopic lithotripsy devices 2022-2028: Research Report on technology, participants, trends, market size and share
Global and Chinese market of core pallets 2022-2028: Research Report on technology, participants, trends, market size and share
Build your own random wallpaper API for free