当前位置:网站首页>It is deeply recognized that the compiler can cause differences in the compilation results
It is deeply recognized that the compiler can cause differences in the compilation results
2022-08-09 16:17:00 【Huang Duoyan】
I used to think that as long as it is a windows system, I am in C language, the api is the same, and the compilation result will be the same.But after reading the practice of netizens and combining my own observations, I strengthened my understanding of the content of the textbook.
Code first:
#include#pragma warning(disable:4996)//If you use devc++, you don't need this linemain(){int count = 0;char i;printf("Enter a number string consisting of 0 and 1, press ctrl+z to end...");while (scanf("%c", &i) != EOF)if (i == '1')count++;printf("You entered %d 1s.", count);}
The picture above shows the result of compiling with vs, and the picture below shows the result of compiling with devc++.Note that the exe compiled with vs is about half the size of devc++.
Next, look at the disassembly.
This is very obvious.The program compiled with vs performs a series of operations on the registers rbp, rdi, rsp, rcx, rax before calling the first sub-process, that is, before executing the call instruction; and using devc++ on the two registers rsp, raxand memory operation.And it can be found that the subtrahend of the subtraction operation on rsp is also different.
Look at the difference in the loaded dll again.
Written in vs: | Written in devc++: |
"cTest.exe" (Win32): "D:\Programming\cTest\x64\Debug\cTest.exe" loaded.Symbols loaded. "cTest.exe" (Win32): "C:\Windows\System32\ntdll.dll" loaded. "cTest.exe" (Win32): "C:\Windows\System32\kernel32.dll" loaded. "cTest.exe" (Win32): "C:\Windows\System32\KernelBase.dll" loaded. "cTest.exe" (Win32): "C:\Windows\System32\vcruntime140d.dll" loaded. "cTest.exe" (Win32): "C:\Windows\System32\ucrtbased.dll" loaded. | "test.exe" (Win32): "D:\Programming\devctest\test.exe" loaded. "test.exe" (Win32): "C:\Windows\System32\ntdll.dll" loaded. "test.exe" (Win32): "C:\Windows\System32\kernel32.dll" loaded. "test.exe" (Win32): "C:\Windows\System32\KernelBase.dll" loaded. "test.exe" (Win32): "C:\Windows\System32\msvcrt.dll" loaded. |
I checked online and found that vcruntime140d.dll is from visual c++ redistributable:
There is also ucrtbased.dll. Note that if you copy these two programs directly to another computer, the ones written in vs will not work properly.I will explore this further when I have time.
So it's true in the textbook that the compiler is also a factor that affects the results of program execution.
边栏推荐
- How to achieve stable profit through the stock quantitative trading interface?
- Mysql two engines comparison
- 生产者/消费者问题(线程信号)
- DSPE-PEG-Hydrazide, DSPE-PEG-HZ, Phospholipid-Polyethylene Glycol-Hydrazide MW: 1000
- How do users correctly understand programmatic trading?
- 简单记录下offsetof和container_of
- 二叉排序树的左旋与右旋
- MySQL学习笔记
- PAT1027 打印沙漏
- FilenameFilter filters filenames
猜你喜欢
卷积神经网络表征可视化研究综述(1)
Startup error: Caused by: org.apache.ibatis.binding.BindingException summary solution
[MySql]实现多表查询-一对一,一对多
Simple analysis of regularization principle (L1 / L2 regularization)
ImageWatch无法显示图像
【C语言初阶】求最小公倍数的三种方法
PAT1027 打印沙漏
常见编译问题
走得通,看得见!你的交通“好帮手”
MySQL principle and optimization: Limit the query optimization
随机推荐
6大论坛,30+技术干货议题,2022首届阿里巴巴开源开放周来了!
注解与反射
How to achieve stable profit through the stock quantitative trading interface?
文件操作的实例——下载并合并流式视频文件
Analysis: Which method is used to build a stock quantitative trading database?
常见的数学物理方程
如何设计一个高并发系统?
股票程序化交易如何理解自己的交易系统?
Seize the opportunity of quantitative trading fund products, and quantitative investment has room for development?
Qt对话框中show和exec的区别
What is an index in MySql?What kinds of indexes are commonly used?When does an index fail?
Shell functions and arrays
Redis6.2.1配置文件详解
经典面试题 之 SQL优化
Arduino 飞鼠 空中鼠标 陀螺仪体感鼠标
多线程学习
bin文档读写
如何保证电脑硬盘格式化后数据不能被恢复?
[MySql]实现多表查询-一对一,一对多
C写菜单指令的快捷方法