2025-12-16 10:20:31 -07:00
|
|
|
# cl
|
|
|
|
|
|
|
|
|
|
> The Microsoft C/C++ compiler for compiling and linking source code files.
|
|
|
|
|
> More information: <https://learn.microsoft.com/cpp/build/reference/compiler-command-line-syntax>.
|
|
|
|
|
|
|
|
|
|
- Compile a source file:
|
|
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
`cl {{path\to\source.c}}`
|
2025-12-16 10:20:31 -07:00
|
|
|
|
|
|
|
|
- Compile and create an executable with a custom name:
|
|
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
`cl /Fe {{path\to\output_executable}} {{path\to\source.c}}`
|
2025-12-16 10:20:31 -07:00
|
|
|
|
|
|
|
|
- Compile a source file with optimization enabled:
|
|
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
`cl /O2 {{path\to\source.c}}`
|
2025-12-16 10:20:31 -07:00
|
|
|
|
|
|
|
|
- Compile a source file and create a debug executable:
|
|
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
`cl /Zi {{path\to\source.c}}`
|
2025-12-16 10:20:31 -07:00
|
|
|
|
|
|
|
|
- Compile multiple source files:
|
|
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
`cl {{path\to\source1.c path\to\source2.c ...}}`
|
2025-12-16 10:20:31 -07:00
|
|
|
|
|
|
|
|
- Specify the output directory for compiled files:
|
|
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
`cl /Fo {{path\to\output_directory}}/ {{path\to\source.c}}`
|
2025-12-16 10:20:31 -07:00
|
|
|
|
|
|
|
|
- Compile with warnings as errors:
|
|
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
`cl /WX {{path\to\source.c}}`
|