Skip to content
Snippets Groups Projects
Commit 1e6ece95 authored by Mactavish's avatar Mactavish
Browse files

add compiler options

parent 8369cd3d
No related branches found
No related tags found
No related merge requests found
...@@ -635,3 +635,19 @@ int main() { ...@@ -635,3 +635,19 @@ int main() {
return 0; 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment