Giter Club home page Giter Club logo

ctestdemo's Introduction

数据存储类型 CTestDemo/png 中有对应ppt,图片解析 C语言程序编译的内存分配 1.栈(stack):编译器自动分配释放,主要存放函数的参数值,局部变量值等; 2.堆(heap):有程序员分配释放 3.全局区或静态区:存放全局变量和静态变量;程序结束时由系统释放,分为全局初始化区和全局未初始化区; 4.字符常量区:常量字符串放与此,程序结束时由系统释放; 5.程序代码区:存放函数体的二进制代码

其中3,4,5经常被统称为数据区,因为他们都是在程序结束时由系统释放 全局变量:存放在函数外的变量 静态变量:由static修饰的变量,只能在本程序文件里面访问,其他文件是无法访问的,可以避免其他文件变量同名 字符常量区:工作原理,如果之前有初始化的同样内容的字符串,下次再创建一个同样的字符串,会先去找有没有同样内容的字符串,有的话直接共用这块内存,没有的话再创建新的

编译各阶段生成的文件,详细请看项目中 CTestDemo/png/编译各阶段文件 文件夹中 hello.c:c语言原文件 1.预处理阶段:处理宏定义指令(替换),条件编译指令,头文件包含指令 hello.i:预处理文件

2.编译阶段:检查代码规范性,是否有语法错误,检查无误后编译成汇编代码;我们C语言编译好的文件,运行时变量,代码等占用不同的内存分区,这个内存分区的决定就在我们编译好生成的这个汇编里面的指令划分一个段,比如有代码段,数据段,堆栈段、主要由我们汇编语言指令决定 hello.s:汇编文件

3.汇编阶段:把编译阶段生成的.s文件转为目标文件(二进制目标代码); hello.o:机器码文件(二进制串)

4.链接阶段:把多个目标文件和函数库链接起来生成可执行文件 hello(hello1):最终可执行文件

ctestdemo's People

Contributors

1024tobe avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.