From 1e6ece95ef8da803fe9586e5fba6abedf205ef12 Mon Sep 17 00:00:00 2001
From: Mactavish <maczhanchao@yahoo.com>
Date: Mon, 24 Apr 2023 13:50:58 +0200
Subject: [PATCH] add compiler options

---
 clang.md | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/clang.md b/clang.md
index 92d5dd3..212081a 100644
--- a/clang.md
+++ b/clang.md
@@ -635,3 +635,19 @@ int main() {
     return 0;
 }
 ```
+
+## Compiler Options
+
+Here are some recommended compiler and linker flags for GCC and Clang:
+
+- `-O2`: optimize your code for speed/space efficiency
+- `-Wall`: turn on recommended compiler warnings (_Always use this option, some of the
+warnings can save you hours of debugging!_)
+- `-Werror`: turn warnings into errors
+- `-g`: enable debugging. Need this option if you want to use a debugger such as GDB.
+- `-o <output filename>`: Name the output executable file with a given filename.
+- `-I <dir>`: add the directory `dir` to the list of directories to be searched for header files.
+- `-std=<standard>`: specify the language standard, e.g. `-std=c11`
+- `-pedantic`: issue warnings demanded by strict conformance to the stardard
+- `-D_FORTIFY_SOURCE=2`: detect runtime buffer overflow
+- `-fpie -Wl,-pie`: enable full ASLR(address space layout randomization) for better security
-- 
GitLab