Code Monkey home page Code Monkey logo

c-language's People

Watchers

 avatar

c-language's Issues

操作系统导论笔记

  1. 虚拟化内存
  • 内存就是一个字节数组,要读取内存,必须指定一个地址,才能访问存储在那里的数据,要写入或更新内存,还必须指定要写入给定地址的数据。
  • 程序的每个指令都在内存中,因此每次读取指令都会访问内存。

制作标准库

库文件描述:
.a 表示静态库文件 .so 表示共享库文件

查看可执行程序链接的库文件

ldd program

bill.c

#include <stdio.h>

void bill(char *arg)
{
	printf("bill: we passwed :[%s]\n", arg);
}

fred.c

#include <stdio.h>

void fred(int arg)
{

	printf("fred: we passwd:[%d]\n", arg);
}

编译成 .o 文件

gcc -c bill.c fred.c
生成 bill.o fred.o 两个文件
将bill.c 与fred.c两个函数增加到lib.h头文件中

lib.h

void fred(int arg);
void bill(char *arg);

编写main函数
program.c

#include <stdio.h>
#include "lib.h"

int main()
{
	bill("hello world");
	fred(772652);
	return 0;
}

生成 .o文件

gcc -c program.c
生成 program.o 文件

  1. 生成 program 可执行程序

gcc -o program program.o bill.o fred.o
./program
执行结果:
bill: we passwed :[hello world]
fred: we passwd:[772652]

  1. 制作库执行文件

ar crv libfoo.a bill.o fred.o

在有的操作系统中需要为函数库生成一个内容表

ranlib libfoo.a

2.1 生成 program 可执行程序

gcc -o program program.o libfoo.a
./program
执行结果:
bill: we passwed :[hello world]
fred: we passwd:[772652]

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.