Code Generation#
In addition to the many gcc options controlling code generation, gdc has several options specific to itself.
- -H#
- Generates D interface files for all modules being compiled. The compiler determines the output file based on the name of the input file, removes any directory components and suffix, and applies the - .disuffix.
- -Hd dir#
- Same as - -H, but writes interface files to directory- dir. This option can be used with- -Hf fileto independently set the output file and directory path.
- -Hf file#
- Same as - -Hbut writes interface files to- file. This option can be used with- -Hd dirto independently set the output file and directory path.
- -M#
- Output the module dependencies of all source files being compiled in a format suitable for make. The compiler outputs one make rule containing the object file name for that source file, a colon, and the names of all imported files. 
- -MF file#
- When used with - -Mor- -MM, specifies a- fileto write the dependencies to. When used with the driver options- -MDor- -MMD,- -MFoverrides the default dependency output file.
- -MG#
- This option is for compatibility with gcc, and is ignored by the compiler. 
- -MP#
- Outputs a phony target for each dependency other than the modules being compiled, causing each to depend on nothing. 
- -MT target#
- Change the - targetof the rule emitted by dependency generation to be exactly the string you specify. If you want multiple targets, you can specify them as a single argument to- -MT, or use multiple- -MToptions.
- -MD#
- This option is equivalent to - -M -MF file. The driver determines- fileby removing any directory components and suffix from the input file, and then adding a- .depssuffix.
- -MMD#
- Like - -MDbut does not mention imported modules from the D standard library package directories.
- -X#
- Output information describing the contents of all source files being compiled in JSON format to a file. The driver determines - fileby removing any directory components and suffix from the input file, and then adding a- .jsonsuffix.
- -fdoc#
- Generates - Ddocdocumentation and writes it to a file. The compiler determines- fileby removing any directory components and suffix from the input file, and then adding a- .htmlsuffix.
- -fdoc-dir=dir#
- Same as - -fdoc, but writes documentation to directory- dir. This option can be used with- -fdoc-file=fileto independently set the output file and directory path.
- -fdoc-file=file#
- Same as - -fdoc, but writes documentation to- file. This option can be used with- -fdoc-dir=dirto independently set the output file and directory path.
- -fdoc-inc=file#
- Specify - fileas a- Ddocmacro file to be read. Multiple- -fdoc-incoptions can be used, and files are read and processed in the same order.
- -fdump-c++-spec=file#
- For D source files, generate corresponding C++ declarations in - file.
- -fdump-c++-spec-verbose#
- In conjunction with - -fdump-c++-spec=above, add comments for ignored declarations in the generated C++ header.
- -fsave-mixins=file#
- Generates code expanded from D - mixinstatements and writes the processed sources to- file. This is useful to debug errors in compilation and provides source for debuggers to show when requested.