大多数的C/C++编译器都支持一个“-M”的选项,即自动找寻源文件中包含的头文件。举个例子,比如mian.c包含有如下头文件。

#include <stdio.h>

#include "log.h"

用gcc -M main.c就可以输入其包含的所有头文件。如下图所示。

[root@bogon CodeNotes]# gcc -M main.c

main.o: main.c /usr/include/stdio.h /usr/include/features.h \

/usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \

/usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \

/usr/lib/gcc/i386-redhat-Linux/4.1.2/include/stddef.h \

/usr/include/bits/types.h /usr/include/bits/typesizes.h \

/usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \

/usr/include/bits/wchar.h /usr/include/gconv.h \

/usr/lib/gcc/i386-redhat-linux/4.1.2/include/stdarg.h \

/usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h log.h

可以看出“-M”参数会把一些标准库的头文件也包含进来。如果你使用GNU的C/C++编译器,你可以用“-MM”参数,它会忽略#include<file>造成的依赖关系,不会显示标准库的头文件,如下图所示。

[root@bogon CodeNotes]# gcc -MM main.c

main.o: main.c log.h

GCC选项之-M的更多相关文章

  1. gcc选项-g与-rdynamic的异同

    摘自http://www.tuicool.com/articles/EvIzUn gcc选项-g与-rdynamic的异同 gcc 的 -g ,应该没有人不知道它是一个调试选项,因此在一般需要进行程序 ...

  2. GCC选项

    -g: Debugging Option. 提供给GDB的debugging信息的选项: -fno-omit-frame-pointer: Optimization Option: -Wstrict- ...

  3. gcc选项-g与-rdynamic的异同_转

    转自:http://www.tuicool.com/articles/EvIzUn gcc 的 -g ,应该没有人不知道它是一个调试选项,因此在一般需要进行程序调试的场景下,我们都会加上该选项,并且根 ...

  4. 常用gcc选项

    <Linux GCC常用命令> Makefile有三个非常有用的变量.分别是$@,$^,$<代表的意义分别是: $@--目标文件,$^--所有的依赖文件,$<--第一个依赖文件 ...

  5. GCC选项_-Wl,-soname 及 DT_NEEDED 的解释

    -Wl选项告诉编译器将后面的参数传递给链接器. -soname则指定了动态库的soname(简单共享名,Short for shared object name) soname的关键功能是它提供了兼容 ...

  6. 【转载】 GNU GCC 选项说明

    GCC 1 Section: GNU Tools (1) Updated: 2003/12/05 Sponsor: GCC Casino Winning Content NAME gcc,g++-GN ...

  7. gcc选项 笔记

    gcc –E hello.c –o hello.i   使用gcc的选项"-E" 让gcc在预处理结束后停止编译过程. gcc –S hello.i –o hello.s   &q ...

  8. GCC选项 –I,-l,-L

    -I:指定第一个寻找头文件的目录 -L:指定第一个寻找库文件的目录 -l:表示在库文件目录中寻找指定的动态库文件 例: gcc –o hello hello.c –I /home/hello/incl ...

  9. Linux下动态链接库 与gcc 选项

    -L 编译时查找动态链接库的路径 -lxxx(小写)  e.g -lcudart   = link libcudart.so  , -I(大写) 头文件的路径 -rpath (-R), 编译时指定链接 ...

随机推荐

  1. redis 4 集群重启与数据导入

    1.redis 4 平时启用aof db与每天的完整备份. 2.集群状态检查 cluster info 检查集群状态 cluster nodes 检查节点状态 redis-cli -c -p 7000 ...

  2. empty 与 remove 的区别

    empty()移除指定元素中的所有子节点,拿$("p").empty()来说,他只是把<p>dsfsd</p>中的文本给移除了,而留下 了<p> ...

  3. Android 实现简单 倒计时60秒,一次1秒

    倒计时功能如上图所示,其实就几行代码即可实现效果啦!!! /** 倒计时60秒,一次1秒 */ CountDownTimer timer = new CountDownTimer(60*1000, 1 ...

  4. python 最简单的爬虫

    import urllib.request file=urllib.request.urlopen("http://www.qq.com") data=file.read() da ...

  5. Codeforces Beta Round #74 (Div. 2 Only)

    Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...

  6. WAV与PCM

    转: 1.PCM格式介绍: PCM(Pulse Code Modulation)也被称为 脉码编码调制.PCM中的声音数据没有被压缩,如果是单声道的文件,采样数据按时间的先后顺序依次存入.(它的基本组 ...

  7. 模块math和cmath

    python使用特殊命令import导入模块,再以module.function的方式使用模块 python标准库提供了一个专门用于处理复数的模块cmath,math处理数据 模块math常用的函数有 ...

  8. thinkphp3.2集成QRcode生成二维码

    一.下载QRcode源代码 https://sourceforge.net/projects/phpqrcode/files/releases/ 使用phpqrcode必须开启GD2扩展,phpqrc ...

  9. materia官网地址

    https://materializecss.com/autocomplete.html

  10. Linux驱动之按键驱动编写(查询方式)

    在Linux驱动之LED驱动编写已经详细介绍了一个驱动的编写过程,接着来写一个按键驱动程序,主要是在file_operations结构中添加了一个read函数.还是分以下几步说明 1.查看原理图,确定 ...