g++, gcc: page update (#7821)

* Update placeholders:
- use "path/to"
- join list of placeholders in gcc

* Suggest language standard in code example

Co-authored-by: Muhammad Falak R Wani <falakreyaz@gmail.com>

Co-authored-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
feature/windows-fix-syntax-2
Emily Grace Seville 2022-03-02 03:36:03 -08:00 committed by GitHub
parent c4a72c36b4
commit 02c427a039
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 10 deletions

View File

@ -6,16 +6,16 @@
- Compile a source code file into an executable binary:
`g++ {{source.cpp}} -o {{output_executable}}`
`g++ {{path/to/source.cpp}} -o {{path/to/output_executable}}`
- Display (almost) all errors and warnings:
`g++ {{source.cpp}} -Wall -o {{output_executable}}`
`g++ {{path/to/source.cpp}} -Wall -o {{path/to/output_executable}}`
- Choose a language standard to compile for(C++98/C++11/C++14/C++17):
- Choose a language standard to compile for (C++98/C++11/C++14/C++17):
`g++ {{source.cpp}} -std={{language_standard}} -o {{output_executable}}`
`g++ {{path/to/source.cpp}} -std={{c++98|c++11|c++14|c++17}} -o {{path/to/output_executable}}`
- Include libraries located at a different path than the source file:
`g++ {{source.cpp}} -o {{output_executable}} -I{{header_path}} -L{{library_path}} -l{{library_name}}`
`g++ {{path/to/source.cpp}} -o {{path/to/output_executable}} -I{{path/to/header}} -L{{path/to/library}} -l{{library_name}}`

View File

@ -5,20 +5,20 @@
- Compile multiple source files into executable:
`gcc {{source1.c}} {{source2.c}} --output {{executable}}`
`gcc {{path/to/source1.c path/to/source2.c ...}} --output {{path/to/output_executable}}`
- Allow warnings, debug symbols in output:
`gcc {{source.c}} -Wall -Og --output {{executable}}`
`gcc {{path/to/source.c}} -Wall -Og --output {{path/to/output_executable}}`
- Include libraries from a different path:
`gcc {{source.c}} --output {{executable}} -I{{header_path}} -L{{library_path}} -l{{library_name}}`
`gcc {{path/to/source.c}} --output {{path/to/output_executable}} -I{{path/to/header}} -L{{path/to/library}} -l{{library_name}}`
- Compile source code into Assembler instructions:
`gcc -S {{source.c}}`
`gcc -S {{path/to/source.c}}`
- Compile source code without linking:
`gcc -c {{source.c}}`
`gcc -c {{path/to/source.c}}`