C有用的GCC标志是什么? [英] What are the useful GCC flags for C?

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

问题描述

除了设置 -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 代码生成选项很有趣:

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 很有用-它会添加一些有用的注释.

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

-finstrument-functions 添加代码以在每个函数入口和出口处调用用户提供的概要分析函数.

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

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

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