有用GCC标志对C [英] Useful GCC flags for C

查看:175
本文介绍了有用GCC标志对C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

除了设置 -Wall ,并设定 -std = XXX ,其他什么真正有用的,但很少有人知道的编译器标志出现在C用?

Beyond setting -Wall, and setting -std=XXX, what other really useful, but less known compiler flags are there for use in C?

我在任何额外的警告特别感兴趣,和/或并把警告变为错误在某些情况下绝对减少任何意外的类型不匹配。

I'm particularly interested in any additional warnings, and/or and turning warnings into errors in some cases to absolutely minimize any accidental type mismatches.

推荐答案

若干的 -f code生成选项很有意思:

Several of the -f code generation options are interesting:


  • -ftrapv 函数会导致程序中止签署整数溢出(正式以不确定的行为,在C)。

  • The -ftrapv function will cause the program to abort on signed integer overflow (formally "undefined behaviour" in C).

-fverbose-ASM ,如果你与 -S 编译是有用的研究汇编输出 - 它增加了一些信息注释

-fverbose-asm is useful if you're compiling with -S to examine the assembly output - it adds some informative comments.

-finstrument函数增加code调用用户提供在每个函数入口和出口点分析功能。

-finstrument-functions adds code to call user-supplied profiling functions at every function entry and exit point.

这篇关于有用GCC标志对C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆