- 🐚作者简介:花神庙码农(专注于Linux、WLAN、TCP/IP、Python等技术方向)
- 🐳博客主页:花神庙码农 ,地址:https://blog.csdn.net/qxhgd
- 🌐系列专栏:Linux技术
- 📰如觉得博主文章写的不错或对你有所帮助的话,还望大家三连支持一下呀!!! 👉关注✨、点赞👍、收藏📂、评论。
- 如需转载请参考转载须知!!
-H
- 此选项用于显示编译过程中每个源文件所包含的头文件。这对于分析头文件的依赖关系非常有用。
- 手册说明:
- Print the name of each header file used, in addition to other normal activities. Each name is indented to show how deep in the ‘#include’ stack it is. Precom- piled header files are also printed, even if they are found to be invalid; an invalid precompiled header file is printed with ‘…x’ and a valid one with ‘…!’ .
-E
- 只进行预处理的操作,可以查看预处理阶段的输出。此选项在之前的文章中有所涉及。
- 手册说明:
- Stop after the preprocessing stage; do not run the compiler proper. The output is in the form of preprocessed source code, which is sent to the standard output. Input files that don’t require preprocessing are ignored.
- 具体使用时,可以结合-v选项使用:
gcc -v -E
-d
- 它表示在编译期间按照指定字母的要求生成调试转储文件。此处记录的这些标志与预处理器相关。
- 手册说明:
Says to make debugging dumps during compilation as specified by letters. The flags documented here are those relevant to the preprocessor. Other letters are interpreted by the compiler proper, or reserved for future versions of GCC, and so are silently ignored. If you specify letters whose behavior conflicts, the result is undefined.See Section 3.17 [Developer Options], page 228, for more information.
-dM
- 可以显示所有宏的定义,会输出#define开头的所有宏定义, 一般要配合-E选项使用。
- 手册说明:
- Instead of the normal output, generate a list of ‘#define’ directives for all the macros defined during the execution of the preprocessor, including predefined macros. This gives you a way of finding out what is predefined in your version of the preprocessor. Assuming you have no file foo.h, the command
touch foo.h; cpp -dM foo.h
shows all the predefined macros.- If you use -dM without the -E option, -dM is interpreted as a syn- onym for -fdump-rtl-mach. See Section “Developer Options” in gcc.
-dD
- 和-dM类似,但是它不包括预定义的宏,并同时输出 “#define ”指令和预处理结果。
- 手册说明:
Like ‘-dM’ except in two respects: it does not include the predefined macros, and it outputs both the ‘#define’ directives and the result of preprocessing. Both kinds of output go to the standard output file.
-dN
- 类似于 “-dD”,但只输出宏名称,不输出它们的展开内容。
- 手册说明:
Like ‘-dD’, but emit only the macro names, not their expansions.
-dI
- 除了输出预处理的结果之外,还要输出 #include 指令。
- 手册说明:
Output ‘#include’ directives in addition to the result of prepro-cessing.
-dU
- 类似于 “-dD”,不过仅输出那些被展开的宏,或者是在预处理器指令中测试了其是否已定义的宏;输出会延迟到该宏被使用或测试的时候;并且,对于那些经过测试但当时未定义的宏,还会输出 “#undef” 指令。
- 手册说明:
Like ‘-dD’ except that only macros that are expanded, or whose definedness is tested in preprocessor directives, are output; the output is delayed until the use or test of the macro; and ‘#undef’ directives are also output for macros tested but undefined at the time.
–verbose
- 可以完整的显示编译和链接过程,比如涉及的编译命令、链接的库、include文件的路径等。
- –verbose等价于-v,使用-v也可以。
- 手册说明:
- Print verbose informations related to basic blocks and arcs.
-Xlinker
- 在 GCC(GNU Compiler Collection)中,Xlinker -Map选项用于生成链接映射文件(Xlinker -Map=a.map),可以查看各个节的内存布局、符号定位(全局符号(变量和函数)的地址)、分析链接过程(链接器在生成可执行文件时执行的步骤与操作)。
- 手册说明:
- Pass option as an option to the linker. You can use this to supply system-specific linker options that GCC does not recognize.
- If you want to pass an option that takes a separate argument, you must use -Xlinker twice, once for the option and once for the argument. For example, to pass -assert definitions, you must write -Xlinker -assert -Xlinker definitions. It does not work to write -Xlinker “-assert definitions”, because this passes the entire string as a single argument, which is not what the linker expects.
- When using the GNU linker, it is usually more convenient to pass arguments to linker options using the option=value syntax than as separate arguments. For > example, you can specify -Xlinker -Map=output.map rather than -Xlinker Map -Xlinker output.map. Other linkers may not support this syntax for command-line options.
如本文对你有些许帮助,欢迎大佬支持我一下(点赞+收藏+关注、关注公众号等),您的支持是我持续创作的竭动力
支持我的方式