指令帮助:

man xxx_command

man 2 xxx_command

man 3 xxx_command

eg. 打开文件的函数open, 如果不清楚传参,则

man open 

man 2  xxx_command 通常在man下面如果出来的不是你想要的,试试man 2:

eg. 写内容到文件函数write

man  write

ps:man后面跟数字的含义:

、Standard commands (标准命令)
、System calls (系统调用)
、Library functions (库函数)
、Special devices (设备说明)
、File formats (文件格式)
、Games and toys (游戏和娱乐)
、Miscellaneous (杂项)
、Administrative Commands (管理员命令)
其他(Linux特定的), 用来存放内核例行程序的文档。

编译&链接:

gcc  -o 可执行文件  源文件.c(或依赖文件)

只编译(得到obj/o文件),不链接

gcc -c 源文件.c

调试支持

gcc -g -o 可执行文件 依赖文件

配合 gdb 可执行文件 就可以调试了。

(ps, 如果调试的时候,命令要跟参数, 参考这里

  即:先 gdb 指令 进入调试, 然后 run 具体参数

调优:

gcc -O -o 目标文件 依赖文件

-O相关的man帮助文档如下:

       The compiler performs optimization based on the knowledge it has of the program.  Compiling multiple files at once to a single output file mode
allows the compiler to use information gained from all of the files when compiling each of them. Not all optimizations are controlled directly by a flag. Only optimizations that have a flag are listed. -O
-O1 Optimize. Optimizing compilation takes somewhat more time, and a lot more memory for a large function. With -O, the compiler tries to reduce code size and execution time, without performing any optimizations that take a great deal of compilation
time. -O turns on the following optimization flags: -fauto-inc-dec -fcprop-registers -fdce -fdefer-pop -fdelayed-branch -fdse -fguess-branch-probability -fif-conversion2 -fif-conversion
-finline-small-functions -fipa-pure-const -fipa-reference -fmerge-constants -fsplit-wide-types -ftree-builtin-call-dce -ftree-ccp -ftree-ch
-ftree-copyrename -ftree-dce -ftree-dominator-opts -ftree-dse -ftree-fre -ftree-sra -ftree-ter -funit-at-a-time -O also turns on -fomit-frame-pointer on machines where doing so does not interfere with debugging. -O2 Optimize even more. GCC performs nearly all supported optimizations that do not involve a space-speed tradeoff. As compared to -O, this
option increases both compilation time and the performance of the generated code. -O2 turns on all optimization flags specified by -O. It also turns on the following optimization flags: -fthread-jumps -falign-functions
-falign-jumps -falign-loops -falign-labels -fcaller-saves -fcrossjumping -fcse-follow-jumps -fcse-skip-blocks -fdelete-null-pointer-checks
-fexpensive-optimizations -fgcse -fgcse-lm -findirect-inlining -foptimize-sibling-calls -fpeephole2 -fregmove -freorder-blocks
-freorder-functions -frerun-cse-after-loop -fsched-interblock -fsched-spec -fschedule-insns -fschedule-insns2 -fstrict-aliasing
-fstrict-overflow -ftree-switch-conversion -ftree-pre -ftree-vrp Please note the warning under -fgcse about invoking -O2 on programs that use computed gotos. -O3 Optimize yet more. -O3 turns on all optimizations specified by -O2 and also turns on the -finline-functions, -funswitch-loops,
-fpredictive-commoning, -fgcse-after-reload, -ftree-vectorize and -fipa-cp-clone options. -O0 Reduce compilation time and make debugging produce the expected results. This is the default. -Os Optimize for size. -Os enables all -O2 optimizations that do not typically increase code size. It also performs further optimizations
designed to reduce code size. -Os disables the following optimization flags: -falign-functions -falign-jumps -falign-loops -falign-labels -freorder-blocks
-freorder-blocks-and-partition -fprefetch-loop-arrays -ftree-vect-loop-version If you use multiple -O options, with or without level numbers, the last such option is the one that is effective.

If you use multiple -O options, with or without level numbers, the last such option is the one that is effective.

Makefile/makefile

一个大工程,有很多文件要编译链接时用到,配合make指令使用。

Makefile编写规则:

目标文件:依赖文件
规则/指令

Makefile的解析方式类似递归算法(暂未看其源码):

  1. 第一行的目标文件即为最终文件

  2. 查看其依赖文件是否存在,存在且为最新的则生成最终文件。结束。否则,跳至3

  3. 查看其(以上的依赖文件的)依赖文件的生成规则是否存在, 不存在报错。存在,则重复以上步骤2,直至生成最终目标文件。

awesome-c

如果想看看c有哪些优秀的开源库,或者想用项目上手,看这里:

https://notabug.org/koz.ross/awesome-c

(不完全译本:https://github.com/jobbole/awesome-c-cn)

其他

http://c.biancheng.net/cpp/u/yuanma/list_62_1.html

linux c 笔记-1的更多相关文章

  1. Linux内核笔记--内存管理之用户态进程内存分配

    内核版本:linux-2.6.11 Linux在加载一个可执行程序的时候做了种种复杂的工作,内存分配是其中非常重要的一环,作为一个linux程序员必然会想要知道这个过程到底是怎么样的,内核源码会告诉你 ...

  2. Linux 学习笔记

    Linux学习笔记 请切换web视图查看,表格比较大,方法:视图>>web板式视图 博客园不能粘贴图片吗 http://wenku.baidu.com/view/bda1c3067fd53 ...

  3. linux学习笔记2-linux的常用命令

    第一篇博客:linux学习笔记1-ubuntu的安装与基本设置 之中,已经介绍了如何安装linux操作系统,以及一些基本的设置修改. 本篇博客主要介绍linux中的一些常用的终端命令 ======== ...

  4. Linux学习笔记(一)2015.4.13

    研究生由单片机转Linux学习 首先安装VMware虚拟机,用的是VMware 10.0 在VMware 10.0上安装视频上推荐的Red Hat Linux 5 安装后正式进入Linux学习 笔记1 ...

  5. 跟着鸟哥学Linux系列笔记3-第11章BASH学习

    跟着鸟哥学Linux系列笔记0-扫盲之概念 跟着鸟哥学Linux系列笔记0-如何解决问题 跟着鸟哥学Linux系列笔记1 跟着鸟哥学Linux系列笔记2-第10章VIM学习 认识与学习bash 1. ...

  6. 跟着鸟哥学Linux系列笔记2-第10章VIM学习

    跟着鸟哥学Linux系列笔记0-扫盲之概念 跟着鸟哥学Linux系列笔记0-如何解决问题 跟着鸟哥学Linux系列笔记1 常用的文本编辑器:Emacs, pico, nano, joe, vim VI ...

  7. 跟着鸟哥学Linux系列笔记0-如何解决问题

    跟着鸟哥学Linux系列笔记0-扫盲之概念 在发生问题怎么处理: 1.  在自己的主机.网络数据库上查询How-To或FAQ -Linux 自身的文件数据: /usr/share/doc -CLDP中 ...

  8. 跟着鸟哥学Linux系列笔记1

    跟着鸟哥学Linux系列笔记0-扫盲之概念 跟着鸟哥学Linux系列笔记0-如何解决问题 装完linux之后,接下来一步就是进行相关命令的学习了 第五章:首次登录与在线求助man page 1. X ...

  9. 【转载】linux内核笔记之进程地址空间

    原文:linux内核笔记之进程地址空间 进程的地址空间由允许进程使用的全部线性地址组成,在32位系统中为0~3GB,每个进程看到的线性地址集合是不同的. 内核通过线性区的资源(数据结构)来表示线性地址 ...

  10. 【转载】linux内核笔记之高端内存映射

    原文:linux内核笔记之高端内存映射 在32位的系统上,内核使用第3GB~第4GB的线性地址空间,共1GB大小.内核将其中的前896MB与物理内存的0~896MB进行直接映射,即线性映射,将剩余的1 ...

随机推荐

  1. node-sass安装不成功的解决方案

    最近在学webpack,需要用到sass-loader加载器解析.scss文件,安装sass-loader,必须先安装node-sass,node-sass纠正了两天,用npm install nod ...

  2. Linux系统1.md

    计算机 介绍 电子计算机(英语:computer),亦称电脑,是一种利用电子学原理,根据一系列指令对数据进行处理的工具. 在现代,机械计算机的应用已经完全被电子计算机所替换,其所相关的技术研究叫计算机 ...

  3. C/C++编程语言学习资料尽收眼底 电子书+视频教程

    Visual C++(VC/MFC)学习电子书及开发工具下载请看这里 史无前例的网络最全最强C/C++资料索引: C/C++编程语言学习资料尽收眼底 电子书+视频教程 VC++/MFC(VC6)开发技 ...

  4. 文件夹右键添加“DOS”命令

    导入注册表 Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Folder\shell\RunCMD] @="进入命令行&quo ...

  5. 阅读ArrayBlockingQueue源码了解如何利用锁实现BlockingQueue

    BlockingQueue是多线程里面一个非常重要的数据结构.在面试的时候,也常会被问到怎么实现BlockingQueue.本篇根据Java7里ArrayBlockingQueue的源码,简单介绍一下 ...

  6. SqlMetal.exe ORM代码生成

    作甚? 先说说这个工具是干啥的,我们所做的程序,或多或少需要存储一些数据到数据库,当然直接使用Sql语句也可以,甚至有些情况下就是要使用sql语句,但对于一些基本的增删改查,对每张表都要写查询语句就显 ...

  7. 2016-2017-2《程序设计与数据结构》学生博客&git@OSC

    2016-2017-2<程序设计与数据结构>学生博客&git@OSC 博客园 20162301张师瑜 20162302杨京典 20162303石亚鑫 20162304张浩林 201 ...

  8. C# 利用反射根据类名创建类的实例对象

    “反射”其实就是利用程序集的元数据信息. 反射可以有很多方法,编写程序时请先导入 System.Reflection 命名空间. 1.假设你要反射一个 DLL 中的类,并且没有引用它(即未知的类型): ...

  9. Azure SQL Data Warehouse

    Azure SQL Data Warehouse & AWS Redshift Amazon Redshift Amazon Redshift 是一种快速.完全托管的 PB 级数据仓库,可方便 ...

  10. 基于CentOS-7.2.15的Mono+jexus镜像

    公司开发及测试的linux环境为CentOS-7.X,因此以CentOS-7.2.15作为基础镜像,镜像尺寸确实比较大,最终Mono-4.6.0.125+Jexus-5.8.1.10镜像尺寸已将近1G ...