SlideShare ist ein Scribd-Unternehmen logo
1 von 7
Downloaden Sie, um offline zu lesen
了解 C/C++ 运行
库

         杨 军
主要分享内容


 1   C/C++ 运行库是什么



 2   C/C++ 运行库的功能



 3   如何减小软件的大小
C/C++ 运行库是什么
  每一个 C/C++ 程序,它的背后都有一套庞大的代码来进行支撑,以使得该
程序能够正常运行。这套代码就是 C/C++ 运行库。 C/C++ 运行库由编绎器提
供。

  它主要有两个作用:实现 C/C++ 标准库函数的和实现 C/C++ 语言的一些机
制。
实现 C/C++ 标准库函数
   C/C++ 运行库的大部分代码都是在实现 C,C++ 标准库函
数 , 如 : printf, fopen, malloc, strlen, time, _beginthreadex,
std::string 等。

 1. 标准库函数与 Windows API 的关系
 2. 需要注意的一些函数。
    a. 使用了 TLS 的库函数 , 比如 _localtime64
    b. _beginthreadex 和 CreateThread()
 3. 动态链接 (MD) 与静态链接 (MT) 。
    a: 链接错误,大部分是因为 lib 的编绎方式不一
 致。
    b: 模块间内存释放 , 谁分配谁释放。
实现 C/C++ 语言机制
  C/C++ 运行库实现了 C/C++ 语言自身的一些语言机制,比
如 main 函数进入前全局变量要完成构造。静态变量的只能初
始化一次,异常处理机制等。


1. 全局变量及类中静态成员变量的初始化。

2. 应用程序的入口函数。

3. 静态变量的初始化
如何减小软件的 Size

1. 模块数非常多,使用 MD 编绎

2. 模块数非常少,使用 MT 编绎

3. 使用 VC6 运行库。

4. 不使用 CRT
Thank you !

    推荐书籍 :
  1. 《程序员的自我修养》

  2. 《 windows 核心编
  程》

Weitere ähnliche Inhalte

Ähnlich wie 110922 knoss-vol26-c++运行库

C++工程实践
C++工程实践C++工程实践
C++工程实践Shuo Chen
 
ajax_onlinemad
ajax_onlinemadajax_onlinemad
ajax_onlinemadKitor23
 
Csharp summary
Csharp summaryCsharp summary
Csharp summarycri fan
 
Csharp summary
Csharp summaryCsharp summary
Csharp summarycri fan
 
Linux c++ 编程之链接与装载 -基础篇--v0.3--20120509
Linux c++ 编程之链接与装载 -基础篇--v0.3--20120509Linux c++ 编程之链接与装载 -基础篇--v0.3--20120509
Linux c++ 编程之链接与装载 -基础篇--v0.3--20120509tidesq
 
第六章 函數與巨集
第六章 函數與巨集第六章 函數與巨集
第六章 函數與巨集shademoon
 
第六章 函數與巨集
第六章 函數與巨集第六章 函數與巨集
第六章 函數與巨集shademoon
 
第六章 函數與巨集
第六章 函數與巨集第六章 函數與巨集
第六章 函數與巨集shademoon
 
第六章 函數與巨集
第六章 函數與巨集第六章 函數與巨集
第六章 函數與巨集shademoon
 
Recycle Open Source Projects
Recycle Open Source ProjectsRecycle Open Source Projects
Recycle Open Source ProjectsGeorge Ang
 
2006 recycle opensourceprojects
2006 recycle opensourceprojects2006 recycle opensourceprojects
2006 recycle opensourceprojectsGeorge Ang
 
C語言 第一章 C語言簡介
C語言 第一章 C語言簡介C語言 第一章 C語言簡介
C語言 第一章 C語言簡介shademoon
 
06 函數與巨集
06 函數與巨集06 函數與巨集
06 函數與巨集shademoon
 

Ähnlich wie 110922 knoss-vol26-c++运行库 (20)

C 1 c
C 1 cC 1 c
C 1 c
 
C 1 c
C 1 cC 1 c
C 1 c
 
C 1 c
C 1 cC 1 c
C 1 c
 
C++
C++C++
C++
 
C+
C+C+
C+
 
C#
C#C#
C#
 
C++工程实践
C++工程实践C++工程实践
C++工程实践
 
ajax_onlinemad
ajax_onlinemadajax_onlinemad
ajax_onlinemad
 
Csharp summary
Csharp summaryCsharp summary
Csharp summary
 
Csharp summary
Csharp summaryCsharp summary
Csharp summary
 
Linux c++ 编程之链接与装载 -基础篇--v0.3--20120509
Linux c++ 编程之链接与装载 -基础篇--v0.3--20120509Linux c++ 编程之链接与装载 -基础篇--v0.3--20120509
Linux c++ 编程之链接与装载 -基础篇--v0.3--20120509
 
第六章 函數與巨集
第六章 函數與巨集第六章 函數與巨集
第六章 函數與巨集
 
第六章 函數與巨集
第六章 函數與巨集第六章 函數與巨集
第六章 函數與巨集
 
第六章 函數與巨集
第六章 函數與巨集第六章 函數與巨集
第六章 函數與巨集
 
第六章 函數與巨集
第六章 函數與巨集第六章 函數與巨集
第六章 函數與巨集
 
How A Compiler Works: GNU Toolchain
How A Compiler Works: GNU ToolchainHow A Compiler Works: GNU Toolchain
How A Compiler Works: GNU Toolchain
 
Recycle Open Source Projects
Recycle Open Source ProjectsRecycle Open Source Projects
Recycle Open Source Projects
 
2006 recycle opensourceprojects
2006 recycle opensourceprojects2006 recycle opensourceprojects
2006 recycle opensourceprojects
 
C語言 第一章 C語言簡介
C語言 第一章 C語言簡介C語言 第一章 C語言簡介
C語言 第一章 C語言簡介
 
06 函數與巨集
06 函數與巨集06 函數與巨集
06 函數與巨集
 

Mehr von Zoom Quiet

产品信息收集系统Infoc的演变
产品信息收集系统Infoc的演变产品信息收集系统Infoc的演变
产品信息收集系统Infoc的演变Zoom Quiet
 
01s0401 go,互联网时代的c语言 许式伟
01s0401 go,互联网时代的c语言   许式伟01s0401 go,互联网时代的c语言   许式伟
01s0401 go,互联网时代的c语言 许式伟Zoom Quiet
 
Zoz pwned-by-the-owner-表惹程序猿
Zoz pwned-by-the-owner-表惹程序猿Zoz pwned-by-the-owner-表惹程序猿
Zoz pwned-by-the-owner-表惹程序猿Zoom Quiet
 
金山云查询系统改进之路1
金山云查询系统改进之路1金山云查询系统改进之路1
金山云查询系统改进之路1Zoom Quiet
 
Zh120226techparty zd-story
Zh120226techparty zd-storyZh120226techparty zd-story
Zh120226techparty zd-storyZoom Quiet
 
Zh120226techparty velocity2011-review
Zh120226techparty velocity2011-reviewZh120226techparty velocity2011-review
Zh120226techparty velocity2011-reviewZoom Quiet
 
Zh120226techparty jeff kit-ios-toolbox
Zh120226techparty jeff kit-ios-toolboxZh120226techparty jeff kit-ios-toolbox
Zh120226techparty jeff kit-ios-toolboxZoom Quiet
 
Velocity2011分享
Velocity2011分享Velocity2011分享
Velocity2011分享Zoom Quiet
 
陈正 Introduction to-sae_python
陈正   Introduction to-sae_python陈正   Introduction to-sae_python
陈正 Introduction to-sae_pythonZoom Quiet
 
111218 zhtechparty-panda讲稿
111218 zhtechparty-panda讲稿111218 zhtechparty-panda讲稿
111218 zhtechparty-panda讲稿Zoom Quiet
 
111218 zhtechparty-移动互联网产品需求分析
111218 zhtechparty-移动互联网产品需求分析111218 zhtechparty-移动互联网产品需求分析
111218 zhtechparty-移动互联网产品需求分析Zoom Quiet
 
111218 zhtechparty-zd-浅谈symbian开发
111218 zhtechparty-zd-浅谈symbian开发111218 zhtechparty-zd-浅谈symbian开发
111218 zhtechparty-zd-浅谈symbian开发Zoom Quiet
 
ImpoImport this, that, and the other thing: custom importersrt not for_y
ImpoImport this, that, and the other thing: custom importersrt not for_yImpoImport this, that, and the other thing: custom importersrt not for_y
ImpoImport this, that, and the other thing: custom importersrt not for_yZoom Quiet
 
Import this, that, and the other thing: custom importers
Import this, that, and the other thing: custom importersImport this, that, and the other thing: custom importers
Import this, that, and the other thing: custom importersZoom Quiet
 
金山卫士界面框架
金山卫士界面框架金山卫士界面框架
金山卫士界面框架Zoom Quiet
 
111030 gztechparty-小路-云时代的mysql
111030 gztechparty-小路-云时代的mysql111030 gztechparty-小路-云时代的mysql
111030 gztechparty-小路-云时代的mysqlZoom Quiet
 

Mehr von Zoom Quiet (20)

42qu thrift1
42qu thrift142qu thrift1
42qu thrift1
 
产品信息收集系统Infoc的演变
产品信息收集系统Infoc的演变产品信息收集系统Infoc的演变
产品信息收集系统Infoc的演变
 
Go courseday3
Go courseday3Go courseday3
Go courseday3
 
Go courseday2
Go courseday2Go courseday2
Go courseday2
 
Go courseday1
Go courseday1Go courseday1
Go courseday1
 
01s0401 go,互联网时代的c语言 许式伟
01s0401 go,互联网时代的c语言   许式伟01s0401 go,互联网时代的c语言   许式伟
01s0401 go,互联网时代的c语言 许式伟
 
Zoz pwned-by-the-owner-表惹程序猿
Zoz pwned-by-the-owner-表惹程序猿Zoz pwned-by-the-owner-表惹程序猿
Zoz pwned-by-the-owner-表惹程序猿
 
金山云查询系统改进之路1
金山云查询系统改进之路1金山云查询系统改进之路1
金山云查询系统改进之路1
 
Zh120226techparty zd-story
Zh120226techparty zd-storyZh120226techparty zd-story
Zh120226techparty zd-story
 
Zh120226techparty velocity2011-review
Zh120226techparty velocity2011-reviewZh120226techparty velocity2011-review
Zh120226techparty velocity2011-review
 
Zh120226techparty jeff kit-ios-toolbox
Zh120226techparty jeff kit-ios-toolboxZh120226techparty jeff kit-ios-toolbox
Zh120226techparty jeff kit-ios-toolbox
 
Velocity2011分享
Velocity2011分享Velocity2011分享
Velocity2011分享
 
陈正 Introduction to-sae_python
陈正   Introduction to-sae_python陈正   Introduction to-sae_python
陈正 Introduction to-sae_python
 
111218 zhtechparty-panda讲稿
111218 zhtechparty-panda讲稿111218 zhtechparty-panda讲稿
111218 zhtechparty-panda讲稿
 
111218 zhtechparty-移动互联网产品需求分析
111218 zhtechparty-移动互联网产品需求分析111218 zhtechparty-移动互联网产品需求分析
111218 zhtechparty-移动互联网产品需求分析
 
111218 zhtechparty-zd-浅谈symbian开发
111218 zhtechparty-zd-浅谈symbian开发111218 zhtechparty-zd-浅谈symbian开发
111218 zhtechparty-zd-浅谈symbian开发
 
ImpoImport this, that, and the other thing: custom importersrt not for_y
ImpoImport this, that, and the other thing: custom importersrt not for_yImpoImport this, that, and the other thing: custom importersrt not for_y
ImpoImport this, that, and the other thing: custom importersrt not for_y
 
Import this, that, and the other thing: custom importers
Import this, that, and the other thing: custom importersImport this, that, and the other thing: custom importers
Import this, that, and the other thing: custom importers
 
金山卫士界面框架
金山卫士界面框架金山卫士界面框架
金山卫士界面框架
 
111030 gztechparty-小路-云时代的mysql
111030 gztechparty-小路-云时代的mysql111030 gztechparty-小路-云时代的mysql
111030 gztechparty-小路-云时代的mysql
 

110922 knoss-vol26-c++运行库

  • 2. 主要分享内容 1 C/C++ 运行库是什么 2 C/C++ 运行库的功能 3 如何减小软件的大小
  • 3. C/C++ 运行库是什么 每一个 C/C++ 程序,它的背后都有一套庞大的代码来进行支撑,以使得该 程序能够正常运行。这套代码就是 C/C++ 运行库。 C/C++ 运行库由编绎器提 供。 它主要有两个作用:实现 C/C++ 标准库函数的和实现 C/C++ 语言的一些机 制。
  • 4. 实现 C/C++ 标准库函数 C/C++ 运行库的大部分代码都是在实现 C,C++ 标准库函 数 , 如 : printf, fopen, malloc, strlen, time, _beginthreadex, std::string 等。 1. 标准库函数与 Windows API 的关系 2. 需要注意的一些函数。 a. 使用了 TLS 的库函数 , 比如 _localtime64 b. _beginthreadex 和 CreateThread() 3. 动态链接 (MD) 与静态链接 (MT) 。 a: 链接错误,大部分是因为 lib 的编绎方式不一 致。 b: 模块间内存释放 , 谁分配谁释放。
  • 5. 实现 C/C++ 语言机制 C/C++ 运行库实现了 C/C++ 语言自身的一些语言机制,比 如 main 函数进入前全局变量要完成构造。静态变量的只能初 始化一次,异常处理机制等。 1. 全局变量及类中静态成员变量的初始化。 2. 应用程序的入口函数。 3. 静态变量的初始化
  • 6. 如何减小软件的 Size 1. 模块数非常多,使用 MD 编绎 2. 模块数非常少,使用 MT 编绎 3. 使用 VC6 运行库。 4. 不使用 CRT
  • 7. Thank you ! 推荐书籍 : 1. 《程序员的自我修养》 2. 《 windows 核心编 程》