2015-08-04 19:18:34 +01:00
|
|
|
# clang
|
|
|
|
|
|
|
|
> Compiler for C, C++, and Objective-C source files. Can be used as a drop-in replacement for GCC.
|
2019-06-03 01:06:36 +01:00
|
|
|
> More information: <https://clang.llvm.org/docs/ClangCommandLineReference.html>.
|
2015-08-04 19:18:34 +01:00
|
|
|
|
2016-01-07 17:31:27 +00:00
|
|
|
- Compile a source code file into an executable binary:
|
2015-08-04 19:18:34 +01:00
|
|
|
|
|
|
|
`clang {{input_source.c}} -o {{output_executable}}`
|
|
|
|
|
2016-01-07 17:31:27 +00:00
|
|
|
- Activate output of all errors and warnings:
|
2015-08-04 19:18:34 +01:00
|
|
|
|
|
|
|
`clang {{input_source.c}} -Wall -o {{output_executable}}`
|
|
|
|
|
2016-01-07 17:31:27 +00:00
|
|
|
- Include libraries located at a different path than the source file:
|
2015-08-04 19:18:34 +01:00
|
|
|
|
|
|
|
`clang {{input_source.c}} -o {{output_executable}} -I{{header_path}} -L{{library_path}} -l{{library_name}}`
|
2018-10-28 17:04:44 +00:00
|
|
|
|
|
|
|
- Compile source code into LLVM Intermediate Representation (IR):
|
|
|
|
|
|
|
|
`clang -S -emit-llvm {{file.c}} -o {{file.ll}}`
|
2021-09-09 20:55:54 +01:00
|
|
|
|
|
|
|
- Compile source code without linking:
|
|
|
|
|
|
|
|
`clang -c {{input_source.c}}`
|
2023-12-02 08:26:47 +00:00
|
|
|
|
|
|
|
- Optimize the compiled program for performance:
|
|
|
|
|
|
|
|
`clang {{path/to/source.c}} -O{{1|2|3|fast}}`
|