指令帮助:

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 2 write

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

1、Standard commands (标准命令)
2、System calls (系统调用)
3、Library functions (库函数)
4、Special devices (设备说明)
5、File formats (文件格式)
6、Games and toys (游戏和娱乐)
7、Miscellaneous (杂项)
8、Administrative Commands (管理员命令)
9 其他(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 modeallows 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 compilationtime.-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, thisoption 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-vrpPlease 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 optimizationsdesigned 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-versionIf 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

转载于:https://www.cnblogs.com/Tommy-Yu/p/5817202.html

linux c 笔记-1相关推荐

  1. linux rcs文件中的ip,linux学习笔记之diff和patch命令

    关键字:Linux 学习笔记 运维 系统 命令 一.命令的功能 diff命令的功能为逐行比较两个文本文件,列出其不同之处.可是做成diff记录也就是补丁. patch就是利用diff制作的补丁来打到文 ...

  2. Linux服务笔记之二:SSH远程登录

    上次,写了用传统的telnet方法来远程管理服务器.今天,写下如何用SSH(Secure SHELL)协议来远程管理服务器.优点:因为SSH基于成熟的公钥加密体系,所以传输的数据会进行加密,保证数据在 ...

  3. (零)我为什么要写Linux学习笔记?

    我对Linux有强烈的好奇心,兴趣:写学习笔记会让我有成就感:我记忆力实在不好.好吧,其实真正原因是:如果我能把自己学到的知识简明扼要的讲出来,写出来,那便证明我真的学懂了我想学的知识.没时间怎么办? ...

  4. [转载]秀脱linux实战笔记linux-kernel-3.0.3实战篇

    +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 秀脱linux实战笔记linux-kernel-3.0.3实战片篇: QQ:     6 ...

  5. linux添加自己的库,Linux学习笔记——例叙makefile 增加自定义共享库

    Linux学习笔记--例说makefile 增加自定义共享库 0.前言 从学习C语言开始就慢慢开始接触makefile,查阅了很多的makefile的资料但总感觉没有真正掌握makefile,如果自己 ...

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

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

  7. Linux 学习笔记之超详细基础linux命令 Part 3

    Linux学习笔记之超详细基础linux命令 by:授客 QQ:1033553122 ---------------------------------接Part 2----------------- ...

  8. Linux学习笔记(二)|常用命令

    Linux学习笔记(二)常用命令 1.文件处理命令 1.1命令格式与目录处理 -ls 功能描述:显示目录文件 原意:list 所在路径:/bin/ls 语法: ls-a 显示所有文件,包括隐藏文件 l ...

  9. Linux学习笔记(一)|目录结构

    Linux学习笔记(一) #一.Linux的目录结构 Linux采用层级式的树状目录结构,根目录为"/",在此目录下创建其他目录. /lib 系统开机所需要最基本的动态链接共享库 ...

  10. Linux 进阶笔记(二)

    这几篇博文主要记录博主的Linux 学习之路,用作以后回顾和参考.大家可以选择略过也可以作参考. (一)Linux 初步笔记 (二)Linux 进阶笔记(一) (三)Linux 进阶笔记(二) (四) ...

最新文章

  1. 华为鸿蒙是多少纳米的,厉害!华为又一颗自研7纳米手机芯片曝光,鸿蒙系统或8月初发布...
  2. python常用内置模块-python常见内置模块collections
  3. 五分钟创建一个自己的NPM包
  4. s3c6410裸机程序(1)
  5. 现在好多人做 局域网聊天
  6. linux xwindow 权限,普通用户如何启动XWindow的问题
  7. C# CookieHelper帮助类
  8. 射频IC理论知识/参考书
  9. elasticjob接入方式和管理端使用
  10. 2022年锂行业研究报告
  11. 95社区(对接第三方社区)
  12. ios 启动图一键生成工具_APP启动图生成
  13. 项目启动大会和项目开工会议的区别
  14. JQuery实现灯箱特效
  15. 用matlab求系统幅度频率响应,matlab频率响应
  16. wex5 tomcat配置php,WeX5 Tomcate 发布
  17. 联想的高清壁纸蛮不错的,速提!
  18. 六月开发语言排行榜出炉
  19. uni-app使用map组件开发map地图,获取后台返回经纬度进行标点
  20. Linux From Scratch v7.0中文版

热门文章

  1. oracle 手动链库,Oracle 数据库干数据库链(Database links)的两个例子
  2. spring的前后台数据传输。
  3. Collectors.counting()
  4. rhel7.5安装mysql8.0教程_RHEL7.5下mysql 8.0.11安装教程
  5. 5g组网sa方式的演进_关于5G的SA(独立组网)和NSA(非独立组网),这篇通俗易懂!
  6. MyBatis基于Java API配置
  7. jQuery核心函数
  8. JavaScript之调用函数的方式
  9. 【渝粤教育】电大中专职业生涯规划_1作业 题库
  10. 【渝粤教育】广东开放大学 民族音乐概论 形成性考核 (58)