Linux command
gdc 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Compile D file
gdc [source.d] -o [output]
Compile with optimization
gdc -O2 [source.d] -o [output]
Enable debug info
gdc -g [source.d] -o [output]
Compile only
gdc -c [source.d]
Link with library
gdc [source.d] -l[library] -o [output]
说明
gdc is the GNU D Compiler, providing a D programming language frontend for the GCC (GNU Compiler Collection) backend. It compiles D source code to native machine code using GCC's proven optimization infrastructure and code generation capabilities. The compiler supports the D2 language specification, including modern features like compile-time function execution (CTFE), mixins, templates, and garbage collection. As a GCC frontend, gdc integrates seamlessly with the GNU toolchain, accepting familiar GCC flags for optimization levels, debugging, linking, and cross-compilation. gdc benefits from GCC's extensive platform support, making D code portable across architectures that GCC supports. It leverages GCC's mature optimization passes, often producing highly efficient native code. The compiler can interoperate with C and C++ code through D's foreign function interface capabilities. While the reference D compiler (DMD) typically implements new language features first, gdc provides broader platform support and benefits from GCC's optimization technology. It's a solid choice for D development when maximum portability, GCC ecosystem integration, or specific optimization characteristics are priorities.
参数
- -o _FILE_
- Output filename.
- -c
- Compile only, no linking.
- -g
- Generate debug information.
- -O _LEVEL_
- Optimization level (0-3).
- -I _PATH_
- Import path.
- -L _FLAG_
- Linker flag.
- --help
- Display help information.
FAQ
What is the gdc command used for?
gdc is the GNU D Compiler, providing a D programming language frontend for the GCC (GNU Compiler Collection) backend. It compiles D source code to native machine code using GCC's proven optimization infrastructure and code generation capabilities. The compiler supports the D2 language specification, including modern features like compile-time function execution (CTFE), mixins, templates, and garbage collection. As a GCC frontend, gdc integrates seamlessly with the GNU toolchain, accepting familiar GCC flags for optimization levels, debugging, linking, and cross-compilation. gdc benefits from GCC's extensive platform support, making D code portable across architectures that GCC supports. It leverages GCC's mature optimization passes, often producing highly efficient native code. The compiler can interoperate with C and C++ code through D's foreign function interface capabilities. While the reference D compiler (DMD) typically implements new language features first, gdc provides broader platform support and benefits from GCC's optimization technology. It's a solid choice for D development when maximum portability, GCC ecosystem integration, or specific optimization characteristics are priorities.
How do I run a basic gdc example?
Run `gdc [source.d] -o [output]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -o _FILE_ do in gdc?
Output filename.