💾 Archived View for gmi.noulin.net › 2021-12-25-gcc-warning-options.gmi captured on 2024-05-12 at 16:17:50. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-07-10)

-=-=-=-=-=-=-

GCC Warning options (and clang)

Feed

date: 2021-12-25 18:16:20

categories: C

firstPublishDate: 2021-12-25 18:16:20

The options listed here are for compiling C programs. They are extra options to make the code less bug prone (like static analyzers).

GCC version 10.2

GCC has warning options helping programmers write better code. When I run tests, I have these options (compiling C):

-g3 -std=gnu11 -fPIC -pipe -mrdrnd -rdynamic -pthread -Wall -Wextra

To make my code more explicit and easier to update in the future, I enabled the following extra warning options:

Here are the warning options I don't use:

For more detailed information about GCC warning options check out the

official GCC documentation

.

Clang version 11

Clang has different options compare to GCC, I compile my programs with both GCC and Clang. When compiling with Clang, I use these warning options:

For more detailed information about Clang warning options check out

Diagnostic flags in Clang (short descriptions)

.

Guides

[https://github.com/ossf/wg-best-practices-os-developers/blob/main/docs/Compiler_Hardening_Guides/Compiler-Options-Hardening-Guide-for-C-and-C++.md](Compiler Options Hardening Guide for C and C++)

hashtags: #cprogramming

Feed