当前位置:网站首页>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 .
边栏推荐
- Detour of Tkinter picture scaling
- 生产中影响滑环质量的因素
- Pit record of Chmod 2 options in deepin
- GPIO circuit principle of stm32
- 找不到实时聊天软件?给你推荐电商企业都在用的!
- Threads and processes
- Day08 ternary operator extension operator character connector symbol priority
- Summary of STM32 serial port sending and receiving data methods
- 万字详解八大排序 必读(代码+动图演示)
- Global and Chinese markets for recycled boilers 2022-2028: Research Report on technology, participants, trends, market size and share
猜你喜欢
Cadence simulation encountered "input.scs": can not open input file change path problem
Oracle-触发器和程序包
Opendrive ramp
Software designer: 03 database system
找不到实时聊天软件?给你推荐电商企业都在用的!
Altium Designer 19.1.18 - 导入板框
[untitled] record the visual shock of the Winter Olympics and the introduction of the display screen
Logistic regression: the most basic neural network
Altium designer 19.1.18 - change the transparency of copper laying
Numpy——1. Creation of array
随机推荐
Global and Chinese market of urban rail connectors 2022-2028: Research Report on technology, participants, trends, market size and share
II Simple NSIS installation package
Acwing - the collection of pet elves - (multidimensional 01 Backpack + positive and reverse order + two forms of DP for the answer)
Linked list (establishment, deletion, insertion and printing of one-way linked list)
Esmini longspeedaction modification
"Source code interpretation" famous programmer TJ's only library
. Net service governance flow limiting middleware -fireflysoft RateLimit
The browser cannot access Baidu
Batch modify the txt file code to UTF-8 (notepad++)
Global and Chinese market of rammers 2022-2028: Research Report on technology, participants, trends, market size and share
Extended application of single chip microcomputer-06 independent key
Global and Chinese market of digital shore durometer 2022-2028: Research Report on technology, participants, trends, market size and share
Anaconda pyhton multi version switching
Opendrive ramp
QT's excellent articles
Random function usage notes
通过sql语句统计特定字段出现次数并排序
Global and Chinese market of quenching furnaces 2022-2028: Research Report on technology, participants, trends, market size and share
[neo4j] common operations of neo4j cypher and py2neo
IEEE access personal contribution experience record