当前位置:网站首页>GCC [7] - compilation checks the declaration of functions, and link checks the definition bugs of functions
GCC [7] - compilation checks the declaration of functions, and link checks the definition bugs of functions
2022-07-06 19:09:00 【Small snails in big cities】
Project scenario :
- I have a problem recently , Let's simplify :
// int xxx();
int main()
{
xxx();
}
- Compile the , Natural compilation, but , The message is :
[email protected]:~/taoge/cpp/test$ g++ -c main.cpp
main.cpp: In function ‘int main()’:
main.cpp:5:9: error: ‘xxx’ was not declared in this scope
xxx();
^
[email protected]:~/taoge/cpp/test$
- Open the above comment , obtain :
int xxx();
int main()
{
xxx();
}
- Compile the , Can you pass ? have a look :
[email protected]:~/taoge/cpp/test$ g++ -c main.cpp
[email protected]:~/taoge/cpp/test$
- Link up , Find out xxx() Undefined .
[email protected]:~/taoge/cpp/test$ g++ main.o
main.o: In function `main': main.cpp:(.text+0x5): undefined reference to `xxx()'
collect2: error: ld returned 1 exit status
So as to confirm the problems in the title .
My wonder at that time was , xxx Function has no definition , Can actually compile . It does . To distinguish between compilation and linking .
Take a closer look at the above English Tips , Compile not pass , It is shown that not declared, And the link doesn't pass , It is shown that undefined. therefore , At a glance .
边栏推荐
- Precautions for binding shortcut keys of QPushButton
- MRO工业品企业采购系统:如何精细化采购协同管理?想要升级的工业品企业必看!
- The nearest library of Qinglong panel
- How are you in the first half of the year occupied by the epidemic| Mid 2022 summary
- RT-Thread 组件 FinSH 使用时遇到的问题
- R language ggplot2 visual time series histogram: visual time series histogram through two-color gradient color matching color theme
- 手写一个的在线聊天系统(原理篇1)
- 包装行业商业供应链管理平台解决方案:布局智慧供应体系,数字化整合包装行业供应链
- A wearable arm device for night and sleeveless blood pressure measurement [translation]
- R语言ggplot2可视化:使用ggpubr包的ggviolin函数可视化小提琴图
猜你喜欢

业务与应用同步发展:应用现代化的策略建议

深度循环网络长期血压预测【翻译】

Handwritten online chat system (principle part 1)
![[matlab] Simulink the input and output variables of the same module cannot have the same name](/img/99/adfe50075010916439cd053b8f04c7.png)
[matlab] Simulink the input and output variables of the same module cannot have the same name

Openmv4 learning notes 1 --- one click download, background knowledge of image processing, lab brightness contrast

Oracle advanced (IV) table connection explanation

AUTOCAD——中心线绘制、CAD默认线宽是多少?可以修改吗?

MRO工业品企业采购系统:如何精细化采购协同管理?想要升级的工业品企业必看!

LeetCode-1279. Traffic light intersection

LeetCode-1279. 红绿灯路口
随机推荐
Based on butterfly species recognition
Precautions for binding shortcut keys of QPushButton
Mathematics in machine learning -- common probability distribution (XIII): Logistic Distribution
LeetCode-1279. 红绿灯路口
安装Mysql报错:Could not create or access the registry key needed for the...
RedisSystemException:WRONGTYPE Operation against a key holding the wrong kind of value
[matlab] Simulink the input and output variables of the same module cannot have the same name
MRO industrial products enterprise procurement system: how to refine procurement collaborative management? Industrial products enterprises that want to upgrade must see!
wx小程序学习笔记day01
R语言ggplot2可视化:使用ggpubr包的ggstripchart函数可视化分组点状条带图(dot strip plot)、设置add参数为不同水平点状条带图添加箱图
[depth first search] Ji suanke: a joke of replacement
R语言使用rchisq函数生成符合卡方分布的随机数、使用plot函数可视化符合卡方分布的随机数(Chi Square Distribution)
The list of people who passed the fifth phase of personal ability certification assessment was published
倒计时2天|腾讯云消息队列数据接入平台(Data Import Platform)直播预告
Detailed idea and code implementation of infix expression to suffix expression
RedisSystemException:WRONGTYPE Operation against a key holding the wrong kind of value
用于远程医疗的无创、无袖带血压测量【翻译】
Yutai micro rushes to the scientific innovation board: Huawei and Xiaomi fund are shareholders to raise 1.3 billion
Nuc11 cheetah Canyon setting U disk startup
R语言ggplot2可视化:使用ggpubr包的ggdotplot函数可视化点阵图(dot plot)、设置palette参数设置不同水平点阵图数据点和箱图的颜色