1167 lines
80 KiB
Plaintext
1167 lines
80 KiB
Plaintext
|
|
<!DOCTYPE html>
|
|
<html lang="en-US">
|
|
<!--
|
|
Copyright (c) 1999-2026 by the D Language Foundation
|
|
All Rights Reserved.
|
|
https://dlang.org/foundation_overview.html
|
|
-->
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="keywords" content="D programming language">
|
|
<meta name="description" content="D Programming Language">
|
|
<title>DMD Compiler for Windows - D Programming Language</title>
|
|
|
|
<link rel="stylesheet" href="css/codemirror.css">
|
|
<link rel="stylesheet" href="css/style.css">
|
|
<link rel="stylesheet" href="css/print.css" media="print">
|
|
<link rel="shortcut icon" href="favicon.ico">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.1, maximum-scale=10.0">
|
|
|
|
</head>
|
|
<body id='DMD Compiler for Windows' class='std dcompiler'>
|
|
<script type="text/javascript">document.body.className += ' have-javascript'</script>
|
|
<div id="top"><div class="helper"><div class="helper expand-container"> <div class="logo"><a href="."><img id="logo" alt="D Logo" src="images/dlogo.svg"></a></div>
|
|
<a href="menu.html" title="Menu" class="hamburger expand-toggle"><span>Menu</span></a>
|
|
|
|
<div id="cssmenu"><ul> <li><a href='https://tour.dlang.org'><span>Learn</span></a></li>
|
|
<li class='expand-container'><a class='expand-toggle' href='documentation.html'><span>Documentation</span></a>
|
|
|
|
<ul class='expand-content'> <li><a href='spec/spec.html'>Language Reference</a></li>
|
|
<li><a href='phobos/index.html'>Library Reference</a></li>
|
|
<li><a href='dmd.html'>Command-line Reference</a></li>
|
|
<li class="menu-divider"><a href='comparison.html'>Feature Overview</a></li>
|
|
<li><a href='articles.html'>Articles</a></li>
|
|
</ul></li>
|
|
<li><a href='download.html'><span>Downloads</span></a></li>
|
|
<li><a href='https://code.dlang.org'><span>Packages</span></a></li>
|
|
<li class='expand-container'><a class='expand-toggle' href='community.html'><span>Community</span></a>
|
|
|
|
<ul class='expand-content'> <li><a href='https://blog.dlang.org'>Blog</a></li>
|
|
<li><a href='orgs-using-d.html'>Orgs using D</a></li>
|
|
<li><a href='https://twitter.com/search?q=%23dlang'>Twitter</a></li>
|
|
<li class="menu-divider"><a href='https://discord.gg/bMZk9Q4'>Discord (community-run)</a></li>
|
|
<li><a href='https://forum.dlang.org'>Forums</a></li>
|
|
<li><a href='irc://irc.libera.chat/d'>IRC</a></li>
|
|
<li><a href='https://wiki.dlang.org'>Wiki</a></li>
|
|
<li class="menu-divider"><a href='bugstats.html'>Issues</a></li>
|
|
<li><a href='contributing.html'>Contributing</a></li>
|
|
<li class="menu-divider"><a href='foundation/contributors.html'>Contributors</a></li>
|
|
<li><a href='foundation/index.html'>Foundation</a></li>
|
|
<li><a href='/security.html'>Security Team</a></li>
|
|
<li class="menu-divider"><a href='https://store.dlang.org/'>Store</a></li>
|
|
<li><a href='foundation/donate.html'>Donate</a></li>
|
|
<li><a href='foundation/sponsors.html'>Sponsors</a></li>
|
|
</ul></li>
|
|
<li class='expand-container'><a class='expand-toggle' href='resources.html'><span>Resources</span></a>
|
|
|
|
<ul class='expand-content'> <li><a href='https://tour.dlang.org'>Tour</a></li>
|
|
<li><a href='https://wiki.dlang.org/Books'>Books</a></li>
|
|
<li><a href='https://wiki.dlang.org/Tutorials'>Tutorials</a></li>
|
|
<li class="menu-divider"><a href='https://wiki.dlang.org/Development_tools'>Tools</a></li>
|
|
<li><a href='https://wiki.dlang.org/Editors'>Editors</a></li>
|
|
<li><a href='https://wiki.dlang.org/IDEs'>IDEs</a></li>
|
|
<li><a href='https://run.dlang.io'>run.dlang.io</a></li>
|
|
<li><a href='http://rainers.github.io/visuald/visuald/StartPage.html'>Visual D</a></li>
|
|
<li class="menu-divider"><a href='acknowledgements.html'>Acknowledgments</a></li>
|
|
<li><a href='dstyle.html'>D Style</a></li>
|
|
<li><a href='spec/glossary.html'>Glossary</a></li>
|
|
<li><a href='sitemap.html'>Sitemap</a></li>
|
|
</ul></li>
|
|
</ul></div>
|
|
<div class="search-container expand-container"> <a href="search.html" class="expand-toggle" title="Search"><span>Search</span></a>
|
|
|
|
<div id="search-box"> <form method="get" action="https://google.com/search">
|
|
<input type="hidden" id="domains" name="domains" value="dlang.org">
|
|
<input type="hidden" id="sourceid" name="sourceid" value="google-search">
|
|
<span id="search-query"><input id="q" name="q" placeholder="Google Search"></span><span id="search-dropdown"><span class="helper"> <select id="sitesearch" name="sitesearch" size="1">
|
|
<option value="dlang.org">Entire Site</option>
|
|
<option value="dlang.org/spec">Language</option>
|
|
<option value="dlang.org/phobos">Library</option>
|
|
<option value="forum.dlang.org">Forums</option>
|
|
|
|
</select>
|
|
</span></span><span id="search-submit"><button type="submit"><i class="fa fa-search"></i><span>go</span></button></span>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div></div></div>
|
|
|
|
<div class="container">
|
|
<div class="subnav-helper"></div> <div class="subnav">
|
|
<div class="head"> <h2>Command-line Reference</h2>
|
|
<p class="Command-line Reference, http://wiki.dlang.org/Development_tools, overview"> <a href="http://wiki.dlang.org/Development_tools">overview</a></p>
|
|
</div>
|
|
<ul><li><a href=' dmd-windows.html'>dmd (Windows)</a></li><li><a href=' dmd-linux.html'>dmd (Linux)</a></li><li><a href=' dmd-osx.html'>dmd (OSX)</a></li><li><a href=' dmd-freebsd.html'>dmd (FreeBSD)</a></li><li><a href=' rdmd.html'>rdmd</a></li><li><a href=' install.html'>install.sh</a></li><li><a href=' htod.html'>htod
|
|
</a></li></ul>
|
|
</div>
|
|
<div class="hyphenate" id="content">
|
|
<div id="tools"><div > <div class="tip smallprint"> <a href="https://github.com/dlang/dlang.org/issues/new?title=%5BDMD Compiler for Windows%5D%20&label=Severity:Enhancement">Report a bug</a>
|
|
<div > If you spot a problem with this page, click here to create a GitHub issue.
|
|
</div>
|
|
</div>
|
|
<div class="tip smallprint"> <a href="https://github.com/dlang/dlang.org/edit/master/dcompiler.dd">Improve this page</a>
|
|
<div > Quickly fork, edit online, and submit a pull request for this page.
|
|
Requires a signed-in GitHub account. This works well for small changes.
|
|
If you'd like to make larger changes you may want to consider using
|
|
a local clone.
|
|
</div>
|
|
</div>
|
|
</div></div>
|
|
<h1>DMD Compiler for Windows</h1>
|
|
|
|
|
|
|
|
|
|
<ul> <li><a href="#requirements">Requirements and Downloads</a></li>
|
|
<li><a href="#installation">Installation</a></li>
|
|
<li><a href="#example">Example</a></li>
|
|
<li><a href="#switches">Compiler Arguments and Switches</a></li>
|
|
<li><a href="#files">Files</a></li>
|
|
<li><a href="#linking">Linking</a></li>
|
|
<li><a href="#environment">Environment Variables</a></li>
|
|
<li><a href="#sc-ini">sc.ini Initialization File</a></li>
|
|
|
|
<li><a href="#problems">Common Installation Problems</a></li>
|
|
<li><a href="#differences">Differences between Windows and Linux versions</a></li>
|
|
<li><a href="#interface-files">D Interface Files</a></li>
|
|
<li><a href="#library">Building Libraries</a></li>
|
|
<li><a href="#compiling-dmd">Compiling dmd</a></li>
|
|
<li><a href="#compiling-phobos">Compiling Phobos</a></li>
|
|
</ul>
|
|
|
|
<h2><a class="anchor" title="Permalink to this section" id="requirements" href="#requirements">Requirements and Downloads</a></h2>
|
|
|
|
<ol> <li><a href="https://dlang.org/download.html">DMD Compiler</a></li>
|
|
|
|
<li>Windows operating system, Windows 7 or later, 32 or 64 bit</li>
|
|
|
|
|
|
|
|
|
|
|
|
</ol>
|
|
|
|
<h2><a class="anchor" title="Permalink to this section" id="installation" href="#installation">Installation</a></h2>
|
|
|
|
<div class="message-box message-box-gray"><b>Hint</b> - The official <a href="download.html">installer</a>
|
|
performs these steps automatically.
|
|
</div>
|
|
<p>Open a console window (for Windows this is done by
|
|
clicking on [Start][Command Prompt]).
|
|
All the tools are command line tools, which means
|
|
they are run from a console window.
|
|
Switch to the root directory.
|
|
Unzip the files in the root directory.
|
|
<span class="d_inlinecode donthyphenate notranslate">dmd.zip</span> will create
|
|
a <span class="d_inlinecode donthyphenate notranslate">\dmd2</span> directory with all the files in it.
|
|
</p>
|
|
|
|
<p>A typical session might look like:</p>
|
|
|
|
<pre class="console notranslate">C:\Documents and Settings\Your Name>cd \
|
|
C:\>unzip dmd.zip
|
|
</pre>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h2><a class="anchor" title="Permalink to this section" id="switches" href="#switches">Compiler Arguments and Switches</a></h2>
|
|
|
|
<dl> <dt><b>dmd</b> <i>files</i>... -<i>switches</i>...
|
|
<dd></dd>
|
|
</dt>
|
|
|
|
<dt><i>files</i>...
|
|
<dd> <center><table><caption>File Extensions</caption> <tr> <th scope="col">Extension</th>
|
|
<th scope="col">File Type</th>
|
|
</tr>
|
|
<tr> <td><b>.c</b></td>
|
|
<td>C source files</td>
|
|
</tr>
|
|
<tr> <td><b>.d</b></td>
|
|
<td>D source files</td>
|
|
</tr>
|
|
<tr> <td><b>.dd</b></td>
|
|
<td><a href="spec/ddoc.html">Ddoc</a> source files</td>
|
|
</tr>
|
|
<tr> <td><b>.di</b></td>
|
|
<td><a href="#interface-files">D interface files</a></td>
|
|
</tr>
|
|
<tr> <td><b>.h</b></td>
|
|
<td>C header files</td>
|
|
</tr>
|
|
<tr> <td><b>.i</b></td>
|
|
<td>preprocessed C source files</td>
|
|
</tr>
|
|
<tr> <td><b>.obj</b></td>
|
|
<td>Object files to link in</td>
|
|
</tr>
|
|
<tr> <td><b>.lib</b></td>
|
|
<td>Object code libraries to search</td>
|
|
</tr>
|
|
<tr> <td><b>.def</b></td>
|
|
<td><a href="http://www.digitalmars.com/ctg/ctgDefFiles.html">module definition file</a></td>
|
|
</tr>
|
|
<tr> <td><b>.res</b></td>
|
|
<td>resource file</td>
|
|
</tr>
|
|
|
|
</table></center>
|
|
</dd>
|
|
</dt>
|
|
|
|
<dt><b>@</b><i>cmdfile</i></dt><dd> If <i>cmdfile</i> is an environment variable,
|
|
read the compiler arguments and switches from
|
|
the value of that variable.
|
|
Otherwise, read compiler arguments and switches from
|
|
the text file <i>cmdfile</i>.
|
|
The file may contain single-line comments starting
|
|
with the hash symbol (<span class="d_inlinecode donthyphenate notranslate">#</span>).
|
|
</dd>
|
|
|
|
<dt><a class="anchor" title="Permalink to this section" id="switch-allinst" href="#switch-allinst"><b>-allinst</b></a></dt><dd>
|
|
Generate code for all template instantiations
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-betterC" href="#switch-betterC"><b>-betterC</b></a></dt><dd>
|
|
Adjusts the compiler to implement D as a <a href="spec/betterc.html">better C</a>:
|
|
<ul> <li>Predefines <span class="d_inlinecode donthyphenate notranslate">D_BetterC</span> <a href="spec/version.html#predefined-versions">version</a>.</li>
|
|
<li><a href="spec/expression.html#AssertExpression">Assert Expressions</a>, when they fail,
|
|
call the C runtime library assert failure function
|
|
rather than a function in the D runtime.</li>
|
|
<li><a href="spec/arrays.html#bounds">Array overflows</a>
|
|
call the C runtime library assert failure function
|
|
rather than a function in the D runtime.</li>
|
|
<li><a href="spec/statement.html#final-switch-statement/">Final switch errors</a>
|
|
call the C runtime library assert failure function
|
|
rather than a function in the D runtime.</li>
|
|
<li>Does not automatically link with phobos runtime library.</li>
|
|
|
|
<li>Module constructors and destructors are not generated meaning that
|
|
<a href="spec/class.html#StaticConstructor">static</a> and
|
|
<a href="spec/class.html#SharedStaticConstructor">shared static constructors</a> and
|
|
<a href="spec/class.html#StaticDestructor">destructors</a>
|
|
will not get called.</li>
|
|
<li><span class="d_inlinecode donthyphenate notranslate">ModuleInfo</span> is not generated.</li>
|
|
<li><a href="phobos/object.html#.TypeInfo"><span class="d_inlinecode donthyphenate notranslate">TypeInfo</span></a>
|
|
instances will not be generated for structs.</li>
|
|
</ul>
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-boundscheck" href="#switch-boundscheck"><b>-boundscheck</b></a>=[<i>on|safeonly|off</i>]</dt><dd>
|
|
Controls if bounds checking is enabled.
|
|
<ul> <li><i>on</i>: Bounds checks are enabled for all code. This is the default.</li>
|
|
<li><i>safeonly</i>: Bounds checks are enabled only in <span class="d_inlinecode donthyphenate notranslate">@safe</span> code.
|
|
This is the default for <a href="#switch-release"><b>-release</b></a> builds.</li>
|
|
<li><i>off</i>: Bounds checks are disabled completely (even in <span class="d_inlinecode donthyphenate notranslate">@safe</span>
|
|
code). This option should be used with caution and as a
|
|
last resort to improve performance. Confirm turning off
|
|
<span class="d_inlinecode donthyphenate notranslate">@safe</span> bounds checks is worthwhile by benchmarking.</li>
|
|
</ul>
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-c" href="#switch-c"><b>-c</b></a></dt><dd>
|
|
Compile only, do not link
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-check" href="#switch-check"><b>-check</b></a>=<i>action</i>[=[<i>on|off|safeonly</i>]]</dt><dd>
|
|
Enable or disable specific checks.
|
|
Overrides default, <a href="#switch-boundscheck"><b>-boundscheck</b></a>, <a href="#switch-release"><b>-release</b></a> and
|
|
<a href="#switch-unittest"><b>-unittest</b></a> options to enable or disable specific checks.
|
|
<em>action</em> can be:
|
|
<ul> <li><b>assert</b>: assertion checking</li>
|
|
<li><b>bounds</b>: array bounds</li>
|
|
<li><b>in</b>: in contracts</li>
|
|
<li><b>invariant</b>: class/struct invariants</li>
|
|
<li><strong>nullderef</strong>: null dereference</li>
|
|
<li><b>out</b>: out contracts</li>
|
|
<li><b>switch</b>: <span class="d_inlinecode donthyphenate notranslate">final switch</span> failure checking</li>
|
|
</ul>
|
|
Each <em>action</em> can be set to:
|
|
<ul> <li><b>on</b>: specified check is enabled.</li>
|
|
<li><b>off</b>: specified check is disabled.</li>
|
|
<li><b>safeonly</b>: check is enabled only in <span class="d_inlinecode donthyphenate notranslate">@safe</span> functions.</li>
|
|
</ul>
|
|
If no setting for <em>action</em> is given, it will default to <span class="d_inlinecode donthyphenate notranslate">on</span>,
|
|
except <span class="d_inlinecode donthyphenate notranslate">nullderef</span> defaults to <span class="d_inlinecode donthyphenate notranslate">off</span>.
|
|
</dd><dt><b>-check</b>=[<i>on|off</i>]</dt><dd>
|
|
Enable or disable all checks above.
|
|
</dd><dt><b>-check</b>=[<i>h|help|?</i>]</dt><dd>
|
|
List information on all available checks
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-checkaction" href="#switch-checkaction"><b>-checkaction</b></a>=[<i>D|C|halt|context</i>]</dt><dd>
|
|
Sets behavior when an assert or an array bounds check fails,
|
|
or a <span class="d_inlinecode donthyphenate notranslate">final switch</span> errors.
|
|
<ul> <li><b>D</b>: Default behavior, which throws an unrecoverable <span class="d_inlinecode donthyphenate notranslate">AssertError</span>.</li>
|
|
<li><b>C</b>: Calls the C runtime library assert failure function.</li>
|
|
<li><b>halt</b>: Executes a halt instruction, terminating the program.</li>
|
|
<li><b>context</b>: Prints the error context as part of the unrecoverable <span class="d_inlinecode donthyphenate notranslate">AssertError</span>.</li>
|
|
</ul>
|
|
</dd><dt><b>-checkaction</b>=[<i>h|help|?</i>]</dt><dd>
|
|
List information on all available check actions
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-checkactionfinally" href="#switch-checkactionfinally"><b>-checkactionfinally</b></a>=[<i>on|off</i>]</dt><dd>
|
|
Default behavior is on. Turning this off means destructors may not run.
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-color" href="#switch-color"><b>-color</b></a></dt><dd>
|
|
Turn colored console output on
|
|
</dd><dt><b>-color</b>=[<i>on|off|auto</i>]</dt><dd>
|
|
Show colored console output. The default depends on terminal capabilities.
|
|
<ul> <li><b>auto</b>: use colored output if a tty is detected (default)</li>
|
|
<li><b>on</b>: always use colored output.</li>
|
|
<li><b>off</b>: never use colored output.</li>
|
|
</ul>
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-conf" href="#switch-conf"><b>-conf</b></a>=<i>filename</i></dt><dd>
|
|
Use config file at <i>filename</i>
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-cov" href="#switch-cov"><b>-cov</b></a></dt><dd>
|
|
Perform <a href="code_coverage.html">code coverage analysis</a> and generate
|
|
<em class="tt">.lst</em> file with report.</dd>
|
|
<pre class="d_code notranslate">dmd -cov -<span class="d_keyword">unittest</span> myprog.d
|
|
</pre>
|
|
|
|
<dt><b>-cov</b>=ctfe</dt><dd>
|
|
Include code executed during CTFE in coverage report
|
|
</dd><dt><b>-cov</b>=<i>nnn</i></dt><dd>
|
|
Perform code coverage analysis, requiring at least <i>nnn</i>% code coverage.
|
|
Options can be combined, e.g. <span class="d_inlinecode donthyphenate notranslate">-cov=100 -cov=ctfe</span>.
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-cpp" href="#switch-cpp"><b>-cpp</b></a>=<i>filename</i></dt><dd>
|
|
Sets the C preprocessor to <i>filename</i>.
|
|
Normally the C preprocessor used by the associated C compiler is used to
|
|
preprocess ImportC files.
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-D" href="#switch-D"><b>-D</b></a></dt><dd>
|
|
<p>Generate <a href="spec/ddoc.html">documentation</a> from source.</p>
|
|
<p>Note: mind the <a href="spec/ddoc.html#security">security considerations</a>.</p>
|
|
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-Dd" href="#switch-Dd"><b>-Dd</b></a><i>directory</i></dt><dd>
|
|
Write documentation file to <i>directory</i> . <a href="#switch-op"><b>-op</b></a>
|
|
can be used if the original package hierarchy should
|
|
be retained
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-Df" href="#switch-Df"><b>-Df</b></a><i>filename</i></dt><dd>
|
|
Write documentation file to <i>filename</i>
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-d" href="#switch-d"><b>-d</b></a></dt><dd>
|
|
Silently allow <a href="deprecate.html">deprecated features</a> and use of symbols with
|
|
<a href="spec/attribute.html#deprecated">deprecated attributes</a>.
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-de" href="#switch-de"><b>-de</b></a></dt><dd>
|
|
Issue an error when deprecated features or symbols are used (halt compilation)
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-dw" href="#switch-dw"><b>-dw</b></a></dt><dd>
|
|
Issue a message when deprecated features or symbols are used (default)
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-debug" href="#switch-debug"><b>-debug</b></a></dt><dd>
|
|
Compile in <a href="spec/version.html#debug">debug</a> code
|
|
</dd><dt><b>-debug</b>=<i>ident</i></dt><dd>
|
|
Compile in debug code with <a href="spec/version.html#debug_specification">debug identifier</a> <i>ident</i>
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-debuglib" href="#switch-debuglib"><b>-debuglib</b></a>=<i>libname</i></dt><dd>
|
|
Link in <i>libname</i> as the default library when
|
|
compiling for symbolic debugging instead of <b>phobos.lib</b>.
|
|
If <i>libname</i> is not supplied, then no default library is linked in.
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-defaultlib" href="#switch-defaultlib"><b>-defaultlib</b></a>=<i>libname</i></dt><dd>
|
|
Link in <i>libname</i> as the default library when
|
|
not compiling for symbolic debugging instead of <b>phobos.lib</b>.
|
|
If <i>libname</i> is not supplied, then no default library is linked in.
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-deps" href="#switch-deps"><b>-deps</b></a></dt><dd>
|
|
Print module dependencies (imports/file/version/debug/lib)
|
|
</dd><dt><b>-deps</b>=<i>filename</i></dt><dd>
|
|
Write module dependencies as text to <i>filename</i>
|
|
(only imports).
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-dllimport" href="#switch-dllimport"><b>-dllimport</b></a>=[<i>none|defaultLibsOnly|externalOnly|all</i>]</dt><dd>
|
|
Which symbols to dllimport implicitly if not defined in a module that is being compiled
|
|
<ul> <li><i>none</i>: None</li>
|
|
<li><i>defaultLibsOnly</i>: Only druntime/Phobos symbols and any from a module that is marked as external to binary</li>
|
|
<li><i>externalOnly</i>: Only symbols found from a module that is marked as external to binary</li>
|
|
<li><i>all</i>: All</li>
|
|
</ul>
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-edition[" href="#switch-edition["><b>-edition[</b></a>=<i>NNNN</i>[<i>filename</i>]]</dt><dd>
|
|
Set edition to default which is 2023, to a particular year <i>NNNN</i>, apply edition only to <i>filename</i>
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-extern-std" href="#switch-extern-std"><b>-extern-std</b></a>=<i>standard</i></dt><dd>
|
|
Set C++ name mangling compatibility with <i>standard</i>.
|
|
Standards supported are:
|
|
<ul> <li><i>c++98</i>: Use C++98 name mangling,
|
|
Sets <span class="d_inlinecode donthyphenate notranslate">__traits(getTargetInfo, "cppStd")</span> to <span class="d_inlinecode donthyphenate notranslate">199711</span></li>
|
|
<li><i>c++11</i> (default): Use C++11 name mangling,
|
|
Sets <span class="d_inlinecode donthyphenate notranslate">__traits(getTargetInfo, "cppStd")</span> to <span class="d_inlinecode donthyphenate notranslate">201103</span></li>
|
|
<li><i>c++14</i>: Use C++14 name mangling,
|
|
Sets <span class="d_inlinecode donthyphenate notranslate">__traits(getTargetInfo, "cppStd")</span> to <span class="d_inlinecode donthyphenate notranslate">201402</span></li>
|
|
<li><i>c++17</i>: Use C++17 name mangling,
|
|
Sets <span class="d_inlinecode donthyphenate notranslate">__traits(getTargetInfo, "cppStd")</span> to <span class="d_inlinecode donthyphenate notranslate">201703</span></li>
|
|
<li><i>c++20</i>: Use C++20 name mangling,
|
|
Sets <span class="d_inlinecode donthyphenate notranslate">__traits(getTargetInfo, "cppStd")</span> to <span class="d_inlinecode donthyphenate notranslate">202002</span></li>
|
|
<li><i>c++23</i>: Use C++23 name mangling,
|
|
Sets <span class="d_inlinecode donthyphenate notranslate">__traits(getTargetInfo, "cppStd")</span> to <span class="d_inlinecode donthyphenate notranslate">202302</span></li>
|
|
</ul>
|
|
</dd><dt><b>-extern-std</b>=[<i>h|help|?</i>]</dt><dd>
|
|
List all supported standards
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-fIBT" href="#switch-fIBT"><b>-fIBT</b></a></dt><dd>
|
|
Generate Indirect Branch Tracking code
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-fPIC" href="#switch-fPIC"><b>-fPIC</b></a></dt><dd>
|
|
Generate position independent code
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-fPIE" href="#switch-fPIE"><b>-fPIE</b></a></dt><dd>
|
|
Generate position independent executables
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-ftime-trace" href="#switch-ftime-trace"><b>-ftime-trace</b></a></dt><dd>
|
|
Measure the time to analyze, call from CTFE, and generate code for a function.
|
|
Events with a time longer than 500 microseconds (adjustable with <span class="d_inlinecode donthyphenate notranslate">-ftime-trace-granularity</span>)
|
|
will be recorded.
|
|
The profiling result is output in the Chrome Trace Event Format,
|
|
<a href="https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview">described here</a>.
|
|
This can be turned into a more readable text file with the included tool <span class="d_inlinecode donthyphenate notranslate">timetrace2txt</span>, or inspected
|
|
with an interactive viewer such as <a href="https://ui.perfetto.dev/">Perfetto</a>.
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-ftime-trace-granularity" href="#switch-ftime-trace-granularity"><b>-ftime-trace-granularity</b></a>=<i>μsecs</i></dt><dd>
|
|
Minimum time granularity (in microseconds) traced by time profiler.
|
|
The default is <span class="d_inlinecode donthyphenate notranslate">500</span>.
|
|
Measured events shorter than the specified time will be discarded from the output.
|
|
Set it too high, and interesting events may not show up in the output.
|
|
Set too low, and the profiler overhead will be larger, and the output will be cluttered with tiny events.
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-ftime-trace-file" href="#switch-ftime-trace-file"><b>-ftime-trace-file</b></a>=<i>filename</i></dt><dd>
|
|
Specify output file for <span class="d_inlinecode donthyphenate notranslate">-ftime-trace</span>.
|
|
By default, the output name is the same as the first object file name, but with the <span class="d_inlinecode donthyphenate notranslate">.time-trace</span> extension appended.
|
|
A different filename can be chosen with this option, including a path relative to the current directory or an absolute path.
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-g" href="#switch-g"><b>-g</b></a></dt><dd>
|
|
Add CodeView symbolic debug info. See
|
|
<a href="https://dlang.org/windbg.html">Debugging on Windows</a>.
|
|
|
|
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-gdwarf" href="#switch-gdwarf"><b>-gdwarf</b></a>=<i>version</i></dt><dd>
|
|
Add DWARF symbolic debug info.
|
|
The value of <i>version</i> may be 3, 4 or 5, defaulting to 3.
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-gf" href="#switch-gf"><b>-gf</b></a></dt><dd>
|
|
Emit debug info for all referenced types.
|
|
Symbolic debug info is emitted for all types referenced by the compiled code,
|
|
even if the definition is in an imported file not currently being compiled.
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-gs" href="#switch-gs"><b>-gs</b></a></dt><dd>
|
|
Always emit stack frame
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-gx" href="#switch-gx"><b>-gx</b></a></dt><dd>
|
|
Adds stack stomp code, which overwrites the stack frame memory upon function exit.
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-H" href="#switch-H"><b>-H</b></a></dt><dd>
|
|
Generate <a href="#interface-files">D interface file</a>
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-Hd" href="#switch-Hd"><b>-Hd</b></a>=<i>directory</i></dt><dd>
|
|
Write D interface file to <i>directory</i>. <a href="#switch-op"><b>-op</b></a>
|
|
can be used if the original package hierarchy should
|
|
be retained.
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-Hf" href="#switch-Hf"><b>-Hf</b></a>=<i>filename</i></dt><dd>
|
|
Write 'header' file to <i>filename</i>
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-HC" href="#switch-HC"><b>-HC</b></a>=[<i>silent|verbose</i>]</dt><dd>
|
|
Write C++ 'header' equivalent to stdout configured with:
|
|
<dl> <dt>silent</dt><dd>only list extern(C[++]) declarations (default)</dd>
|
|
<dt>verbose</dt><dd>also add comments for ignored declarations (e.g. extern(D))</dd>
|
|
</dl>
|
|
</dd><dt><b>-HC</b>=[<i>?|h|help</i>]</dt><dd>
|
|
List available options for C++ 'header' file generation
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-HCd" href="#switch-HCd"><b>-HCd</b></a>=<i>directory</i></dt><dd>
|
|
Write C++ 'header' file to <i>directory</i>, ignored if <span class="d_inlinecode donthyphenate notranslate">-HCf=<i>filename</i></span> is not present
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-HCf" href="#switch-HCf"><b>-HCf</b></a>=<i>filename</i></dt><dd>
|
|
Write C++ 'header' file to <i>filename</i> instead of stdout
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch--help" href="#switch--help"><b>--help</b></a></dt><dd>
|
|
Print help and exit
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-I" href="#switch-I"><b>-I</b></a>=<i>directory</i></dt><dd>
|
|
<p>Adds <i>directory</i> to the list of paths to be searched for imports.
|
|
Multiple <span class="d_inlinecode donthyphenate notranslate">-I</span>'s can be used, and the paths are searched in the same order.</p>
|
|
|
|
<p>The process of finding a module during the resolution of an import
|
|
declaration involves several steps.
|
|
<ul> <li><b>Search paths</b>: <b>dmd</b> searches for the module in all directories
|
|
specified with the <a href="#switch-I"><b>-I</b></a> option in the following sequence:
|
|
<ol> <li>From the command line.</li>
|
|
|
|
<li>From the <span class="d_inlinecode donthyphenate notranslate">DFLAGS</span> setting in the
|
|
<a href="#sc-ini sc.ini"></a>
|
|
initialization file.</li>
|
|
|
|
<li>From the <a href="#environment DFLAGS"></a> environment variable if
|
|
no setting was found in the initialization file.</li>
|
|
|
|
<li>If the module cannot be found in any of the import paths, then the
|
|
current working directory is searched instead.</li>
|
|
</ol>
|
|
</li>
|
|
<li><b>Module name mapping</b>: The chain of identifiers in a
|
|
<a href="spec/module.html#ModuleFullyQualifiedName">fully qualified</a>
|
|
module name is translated into a corresponding file name. This involves:
|
|
<ul> <li>Replacing dots (<span class="d_inlinecode donthyphenate notranslate">.</span>) in the module name with directory separators
|
|
(<span class="d_inlinecode donthyphenate notranslate">\</span>).</li>
|
|
|
|
<li>Appending the appropriate file extension.</li>
|
|
|
|
<li>Look for a package module if the file name is a directory.</li>
|
|
</ul>
|
|
</li>
|
|
<li><b>File extensions</b>: Modules are matched to files with specific
|
|
file extensions. The order in which each extension is searched is as follows:
|
|
<ol> <li><span class="d_inlinecode donthyphenate notranslate">.di</span></li>
|
|
<li><span class="d_inlinecode donthyphenate notranslate">.d</span></li>
|
|
<li><span class="d_inlinecode donthyphenate notranslate">package.di</span></li>
|
|
<li><span class="d_inlinecode donthyphenate notranslate">package.d</span></li>
|
|
<li><span class="d_inlinecode donthyphenate notranslate">.i</span></li>
|
|
<li><span class="d_inlinecode donthyphenate notranslate">.h</span></li>
|
|
<li><span class="d_inlinecode donthyphenate notranslate">.c</span></li>
|
|
</ol>
|
|
</li>
|
|
<li><b>Module filename aliases</b>: The relationship between module names and their
|
|
corresponding source files can be defined explicitly with the <a href="#switch-mv"><b>-mv</b></a>
|
|
command line option. For example, <span class="d_inlinecode donthyphenate notranslate">-mv=foo=source</span> or <span class="d_inlinecode donthyphenate notranslate">-mv=foo.bar=source/file.d</span>.
|
|
<ol> <li>When an imported module matches a module filename alias, then the
|
|
filename spec is used as the source file location. File name extensions are
|
|
checked in order if no extension was given in the filename spec.</li>
|
|
|
|
<li>When the package name of an imported module matches a module filename
|
|
alias, then the filename spec is used as the search path. No other search
|
|
paths are used to locate the module.</li>
|
|
</ol>
|
|
</li>
|
|
</ul></p>
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-extI" href="#switch-extI"><b>-extI</b></a>=<i>directory</i></dt><dd>
|
|
Look for imports that are out of the currently compiling binary, used to set the module as DllImport
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-i[" href="#switch-i["><b>-i[</b></a><i>=<i>pattern</i></i>]</dt><dd>
|
|
<p>Enables "include imports" mode, where the compiler will include imported
|
|
modules in the compilation, as if they were given on the command line. By default, when
|
|
this option is enabled, all imported modules are included except those in
|
|
druntime/phobos. This behavior can be overridden by providing patterns via <span class="d_inlinecode donthyphenate notranslate">-i=<i>pattern</i></span>.
|
|
A pattern of the form <span class="d_inlinecode donthyphenate notranslate">-i=<i>package</i></span> is an "inclusive pattern", whereas a pattern
|
|
of the form <span class="d_inlinecode donthyphenate notranslate">-i=-<i>package</i></span> is an "exclusive pattern". Inclusive patterns will include
|
|
all module's whose names match the pattern, whereas exclusive patterns will exclude them.
|
|
For example. all modules in the package <span class="d_inlinecode donthyphenate notranslate">foo.bar</span> can be included using <span class="d_inlinecode donthyphenate notranslate">-i=foo.bar</span> or excluded
|
|
using <span class="d_inlinecode donthyphenate notranslate">-i=-foo.bar</span>. Note that each component of the fully qualified name must match the
|
|
pattern completely, so the pattern <span class="d_inlinecode donthyphenate notranslate">foo.bar</span> would not match a module named <span class="d_inlinecode donthyphenate notranslate">foo.barx</span>.</p>
|
|
|
|
<p>The default behavior of excluding druntime/phobos is accomplished by internally adding a
|
|
set of standard exclusions, namely, <span class="d_inlinecode donthyphenate notranslate">-i=-std -i=-core -i=-etc -i=-object</span>. Note that these
|
|
can be overridden with <span class="d_inlinecode donthyphenate notranslate">-i=std -i=core -i=etc -i=object</span>.</p>
|
|
|
|
<p>When a module matches multiple patterns, matches are prioritized by their component length, where
|
|
a match with more components takes priority (i.e. pattern <span class="d_inlinecode donthyphenate notranslate">foo.bar.baz</span> has priority over <span class="d_inlinecode donthyphenate notranslate">foo.bar</span>).</p>
|
|
|
|
<p>By default modules that don't match any pattern will be included. However, if at
|
|
least one inclusive pattern is given, then modules not matching any pattern will
|
|
be excluded. This behavior can be overridden by usig <span class="d_inlinecode donthyphenate notranslate">-i=.</span> to include by default or <span class="d_inlinecode donthyphenate notranslate">-i=-.</span> to
|
|
exclude by default.</p>
|
|
|
|
<p>Note that multiple <span class="d_inlinecode donthyphenate notranslate">-i=...</span> options are allowed, each one adds a pattern.</p>
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-identifiers" href="#switch-identifiers"><b>-identifiers</b></a>=[<i>UAX31|c99|c11|all</i>]</dt><dd>
|
|
Set the identifier table to use for the non-ASCII values.
|
|
<ul> <li><i>UAX31</i>: UAX31</li>
|
|
<li><i>c99</i>: C99</li>
|
|
<li><i>c11</i>: C11</li>
|
|
<li><i>all</i>: All, the least restrictive set, which comes with all others (default)</li>
|
|
</ul>
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-identifiers-importc" href="#switch-identifiers-importc"><b>-identifiers-importc</b></a>=[<i>UAX31|c99|c11|all</i>]</dt><dd>
|
|
Set the identifier table to use for the non-ASCII values.
|
|
<ul> <li><i>UAX31</i>: UAX31</li>
|
|
<li><i>c99</i>: C99</li>
|
|
<li><i>c11</i>: C11 (default)</li>
|
|
<li><i>all</i>: All, the least restrictive set, which comes with all others</li>
|
|
</ul>
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-ignore" href="#switch-ignore"><b>-ignore</b></a></dt><dd>
|
|
Deprecated flag, unsupported pragmas are always ignored now
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-inline" href="#switch-inline"><b>-inline</b></a></dt><dd>
|
|
Inline functions at the discretion of the compiler.
|
|
This can improve performance, at the expense of making
|
|
it more difficult to use a debugger on it.
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-J" href="#switch-J"><b>-J</b></a>=<i>directory</i></dt><dd>
|
|
Where to look for files for
|
|
<a href="spec/expression.html#ImportExpression"><i>ImportExpression</i></a>s.
|
|
This switch is required in order to use <i>ImportExpression</i>s.
|
|
<i>directory</i> is a <span class="d_inlinecode donthyphenate notranslate">;</span> separated
|
|
list of paths. Multiple <em class="tt">-J</em>'s can be used, and the paths
|
|
are searched in the same order.
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-L" href="#switch-L"><b>-L</b></a>=<i>linkerflag</i></dt><dd>
|
|
Pass <i>linkerflag</i> to the
|
|
linker <a href="http://www.digitalmars.com/ctg/optlink.html">optlink.exe</a>
|
|
, for example, ld
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-lib" href="#switch-lib"><b>-lib</b></a></dt><dd>
|
|
Generate library file as output instead of object file(s).
|
|
All compiled source files, as well as object files and library
|
|
files specified on the command line, are inserted into
|
|
the output library.
|
|
Compiled source modules may be partitioned into several object
|
|
modules to improve granularity.
|
|
The name of the library is taken from the name of the first
|
|
source module to be compiled. This name can be overridden with
|
|
the <a href="#switch-of"><b>-of</b></a> switch.
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-lowmem" href="#switch-lowmem"><b>-lowmem</b></a></dt><dd>
|
|
Enable the garbage collector for the compiler, reducing the
|
|
compiler memory requirements but increasing compile times.
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-m32" href="#switch-m32"><b>-m32</b></a></dt><dd>
|
|
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-m32mscoff" href="#switch-m32mscoff"><b>-m32mscoff</b></a></dt><dd>
|
|
Generate 32 bit code and write MS-COFF object files (deprecated use <span class="d_inlinecode donthyphenate notranslate">-m32</span>)
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-m64" href="#switch-m64"><b>-m64</b></a></dt><dd>
|
|
|
|
The generated object code is in MS-COFF and is meant to be used with the
|
|
<a href="https://msdn.microsoft.com/en-us/library/dd831853(v=vs.100).aspx">Microsoft Visual Studio 10</a>
|
|
or later compiler.
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-marm64" href="#switch-marm64"><b>-marm64</b></a></dt><dd>
|
|
Compile an Arm 64 bit executable. Only supported for OSX.
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-main" href="#switch-main"><b>-main</b></a></dt><dd>
|
|
Add a default <span class="d_inlinecode donthyphenate notranslate">main()</span> function when compiling. This is useful when
|
|
unittesting a library, as it enables running the unittests
|
|
in a library without having to manually define an entry-point function.
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-makedeps[" href="#switch-makedeps["><b>-makedeps[</b></a><i>=<i>filename</i></i>]</dt><dd>
|
|
Print dependencies in Makefile compatible format.
|
|
If <i>filename</i> is omitted, it prints to stdout.
|
|
The emitted targets are the compiled artifacts (executable, object files, libraries).
|
|
The emitted dependencies are imported modules and imported string files (via <a href="#switch-J"><b>-J</b></a> switch).
|
|
Special characters in a dependency or target filename are escaped in the GNU Make manner.
|
|
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-man" href="#switch-man"><b>-man</b></a></dt><dd>
|
|
Open default browser on this page
|
|
|
|
|
|
|
|
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-map" href="#switch-map"><b>-map</b></a></dt><dd>
|
|
Generate a <em class="tt">.map</em> file
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-mcpu" href="#switch-mcpu"><b>-mcpu</b></a>=[<i>baseline|avx|native</i>]</dt><dd>
|
|
Set the target architecture for code generation,
|
|
where:
|
|
<dl> <dt>baseline</dt><dd>the minimum architecture for the target platform (default)</dd>
|
|
<dt>avx</dt><dd> generate <a href="https://en.wikipedia.org/wiki/Advanced_Vector_Extensions">AVX</a>
|
|
instructions instead of <a href="https://en.wikipedia.org/wiki/Streaming_SIMD_Extensions">SSE</a>
|
|
instructions for vector and floating point operations.
|
|
Not available for 32 bit memory models other than OSX32.
|
|
</dd>
|
|
<dt>native</dt><dd>use the architecture the compiler is running on</dd>
|
|
</dl>
|
|
</dd><dt><b>-mcpu</b>=[<i>h|help|?</i>]</dt><dd>
|
|
List all architecture options
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-mixin" href="#switch-mixin"><b>-mixin</b></a>=<i>filename</i></dt><dd>
|
|
Expand and save mixins to file specified by <i>filename</i>
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-mscrtlib" href="#switch-mscrtlib"><b>-mscrtlib</b></a>=<i>libname</i></dt><dd>
|
|
If building MS-COFF object files when targeting Windows, embed a reference to
|
|
the given C runtime library <i>libname</i> into the object file containing <span class="d_inlinecode donthyphenate notranslate">main</span>,
|
|
<span class="d_inlinecode donthyphenate notranslate">DllMain</span> or <span class="d_inlinecode donthyphenate notranslate">WinMain</span> for automatic linking. The default is <em class="tt">libcmt</em>
|
|
(release version with static linkage), which uses the Universal CRT (UCRT)
|
|
shipped with Visual Studio 2015 (or later) and the Windows 10 SDK. The other
|
|
usual alternatives are <em class="tt">libcmtd</em>, <em class="tt">msvcrt</em> and <em class="tt">msvcrtd</em>.
|
|
If no Universal CRT capable Visual C installation is detected, the UCRT-based
|
|
libraries bundled with DMD (the mingw <em class="tt">ucrtbase.lib</em> and
|
|
<em class="tt">vcruntime140.lib</em>) are linked instead using the LLD linker provided by the
|
|
LLVM project.
|
|
If <i>libname</i> is empty, no C runtime library is automatically linked in.
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-mv" href="#switch-mv"><b>-mv</b></a>=<i>package.module</i>=<i>filespec</i></dt><dd>
|
|
Use <i>path/filename</i> as the source file for <i>package.module</i>.
|
|
This is used when the source file path and names are not the same
|
|
as the package and module hierarchy.
|
|
The rightmost components of the <i>path/filename</i> and <i>package.module</i>
|
|
can be omitted if they are the same.
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-noboundscheck" href="#switch-noboundscheck"><b>-noboundscheck</b></a></dt><dd>
|
|
Turns off all array bounds checking, even for safe functions. <span class="red">Deprecated
|
|
(use <em class="tt"><a href="#switch-boundscheck"><b>-boundscheck</b></a>=off</em> instead).</span>
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-nothrow" href="#switch-nothrow"><b>-nothrow</b></a></dt><dd>
|
|
Turns off generation of exception stack unwinding code, enables
|
|
more efficient code for RAII objects. Note: this doesn't change
|
|
function mangling, so it is possible to link <span class="d_inlinecode donthyphenate notranslate">-nothrow</span> code with
|
|
code that throws Exceptions, which can result in undefined behavior
|
|
without any protection from the type system. Prefer the <span class="d_inlinecode donthyphenate notranslate">nothrow</span>
|
|
function attribute for partial disabling of Exceptions instead,
|
|
and only use this flag to globally disable Exceptions.
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-nothrow-optimizations" href="#switch-nothrow-optimizations"><b>-nothrow-optimizations</b></a></dt><dd>
|
|
Controls whether <span class="d_inlinecode donthyphenate notranslate">finally</span> blocks are emitted when the try body is <span class="d_inlinecode donthyphenate notranslate">nothrow</span>.
|
|
By default, finally blocks always run, ensuring cleanup on <span class="d_inlinecode donthyphenate notranslate">Error</span> as well.
|
|
With this option, finally blocks are skipped in nothrow try bodies, which may prevent
|
|
destructors and scope(exit) blocks (which implicitly generate a try-finally block)
|
|
from running when an <span class="d_inlinecode donthyphenate notranslate">Error</span> is thrown.
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-O" href="#switch-O"><b>-O</b></a></dt><dd>
|
|
Optimize generated code. For fastest executables, compile
|
|
with the <em class="tt"><a href="#switch-O"><b>-O</b></a> <a href="#switch-release"><b>-release</b></a> <a href="#switch-inline"><b>-inline</b></a> <a href="#switch-boundscheck"><b>-boundscheck</b></a>=off</em>
|
|
switches together.
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-o-" href="#switch-o-"><b>-o-</b></a></dt><dd>
|
|
Suppress generation of object file. Useful in
|
|
conjuction with <a href="#switch-D"><b>-D</b></a> or <a href="#switch-H"><b>-H</b></a> flags.
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-od" href="#switch-od"><b>-od</b></a>=<i>directory</i></dt><dd>
|
|
Write object files relative to <i>directory</i>
|
|
instead of to the current directory. <a href="#switch-op"><b>-op</b></a>
|
|
can be used if the original package hierarchy should
|
|
be retained
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-of" href="#switch-of"><b>-of</b></a>=<i>filename</i></dt><dd>
|
|
Set output file name to <i>filename</i> in the output
|
|
directory. The output file can be an object file,
|
|
executable file, or library file depending on the other
|
|
switches.
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-op" href="#switch-op"><b>-op</b></a></dt><dd>
|
|
Preserve source path for output files.
|
|
Normally the path for <b>.d</b> source files is stripped
|
|
off when generating an object, interface, or Ddoc file
|
|
name.
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-oq" href="#switch-oq"><b>-oq</b></a></dt><dd>
|
|
Write object files with fully qualified file names.
|
|
When compiling <span class="d_inlinecode donthyphenate notranslate">pkg/app.d</span>, the resulting object file name will be <span class="d_inlinecode donthyphenate notranslate">pkg_app.o</span>
|
|
instead of <span class="d_inlinecode donthyphenate notranslate">app.o</span>. This helps to prevent name conflicts when compiling multiple
|
|
packages in the same directory with the <a href="#switch-od"><b>-od</b></a> flag.
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-os" href="#switch-os"><b>-os</b></a>=<i>os</i></dt><dd>
|
|
Set the target operating system as other than the host.
|
|
<ul> <li><i>host</i>: Target the host operating system (default).</li>
|
|
<li><i>dragonflybsd</i>: DragonFlyBSD</li>
|
|
<li><i>freebsd</i>: FreeBSD</li>
|
|
<li><i>linux</i>: Linux</li>
|
|
<li><i>openbsd</i>: OpenBSD</li>
|
|
<li><i>osx</i>: OSX</li>
|
|
<li><i>solaris</i>: Solaris</li>
|
|
<li><i>hurd</i>: Hurd</li>
|
|
<li><i>windows</i>: Windows</li>
|
|
</ul>
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-P" href="#switch-P"><b>-P</b></a>=<i>preprocessorflag</i></dt><dd>
|
|
Pass <i>preprocessorflag</i> to
|
|
<span class="d_inlinecode donthyphenate notranslate">cl.exe</span>
|
|
. See also <a href="#switch-cpp"><b>-cpp</b></a>
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-preview" href="#switch-preview"><b>-preview</b></a>=<i>name</i></dt><dd>
|
|
Preview an upcoming language change identified by <i>name</i>
|
|
</dd><dt><b>-preview</b>=[<i>h|help|?</i>]</dt><dd>
|
|
List all upcoming language changes
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-profile" href="#switch-profile"><b>-profile</b></a></dt><dd>
|
|
Instrument the generated code so that runtime performance data is collected
|
|
when the generated program is run.
|
|
Upon completion of the generated program, the files <em class="tt">trace.log</em> and <em class="tt">trace.def</em>
|
|
are generated. <em class="tt">trace.log</em> has two sections:
|
|
<ol> <li>Fan in and fan out for each profiled function. The name of the function is left-justified,
|
|
the functions immediately preceding it are the other functions that call it (fan in) and how many times
|
|
it is called. The functions immediately following are the functions that are called (fan out) and how
|
|
many times it calls that function. The function itself has 3 numbers appended: the aggregate of the fan in counts,
|
|
the tree time used by the function which is the function time plus the tree times of all the functions it calls,
|
|
and the time used excluding
|
|
the time used by fan out.
|
|
</li>
|
|
<li>Timing data for each function, sorted from most used to least.</li>
|
|
</ol>
|
|
The <em class="tt">trace.def</em> file contains linker commands to associate functions which are strongly coupled
|
|
so they appear adjacent in the resulting executable file.
|
|
For more information see <a href="https://www.digitalmars.com/ctg/trace.html">profile</a>.
|
|
|
|
</dd><dt><b>-profile</b>=gc</dt><dd>
|
|
Instrument calls to GC memory allocation and
|
|
write a report to the file <em class="tt">profilegc.log</em> upon program
|
|
termination. <b>Note:</b> Only instrumented calls will be
|
|
logged. These include:
|
|
<ul> <li>Language constructs that allocate memory</li>
|
|
<li>Phobos functions that allocate GC memory</li>
|
|
<li>GC allocations via core.memory.GC</li>
|
|
</ul>
|
|
Allocations made by other means will not be logged,
|
|
including direct calls to the GC's C API.
|
|
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-release" href="#switch-release"><b>-release</b></a></dt><dd>
|
|
Compile release version, which means not emitting run-time
|
|
checks for contracts and asserts. Array bounds checking is not
|
|
done for system and trusted functions, and assertion failures
|
|
are undefined behaviour.
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-revert" href="#switch-revert"><b>-revert</b></a>=<i>name</i></dt><dd>
|
|
Revert language change identified by <i>name</i>
|
|
</dd><dt><b>-revert</b>=[<i>h|help|?</i>]</dt><dd>
|
|
List all revertable language changes
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-run " href="#switch-run "><b>-run </b></a><i>srcfile</i> <i>args</i></dt><dd>
|
|
Compile, link, and run the program <i>srcfile</i> with the
|
|
rest of the
|
|
command line, <i>args...</i>, as the arguments to the program.
|
|
No <em class="tt">.obj</em> or executable file is left behind.
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-shared" href="#switch-shared"><b>-shared</b></a></dt><dd>
|
|
|
|
Generate DLL library
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-target" href="#switch-target"><b>-target</b></a>=<i>arch</i>-[<i>vendor-</i>]<i>os</i>[-<i>cenv</i>[<i>-<i>cppenv</i></i>]]</dt><dd>
|
|
Set CPU architecture, OS, C runtime and C++ runtime:
|
|
<ul> <li><i>arch</i> is the architecture: either <span class="d_inlinecode donthyphenate notranslate">x86</span>, <span class="d_inlinecode donthyphenate notranslate">x64</span>, <span class="d_inlinecode donthyphenate notranslate">x86_64</span> or <span class="d_inlinecode donthyphenate notranslate">x32</span></li>
|
|
<li><i>vendor</i> is always ignored, but supported for easier interoperability</li>
|
|
<li><i>os</i> is the operating system, this may have a trailing version number:</li>
|
|
<ul> <li><span class="d_inlinecode donthyphenate notranslate">freestanding</span> for no operating system</li>
|
|
<li><span class="d_inlinecode donthyphenate notranslate">darwin</span> or <span class="d_inlinecode donthyphenate notranslate">osx</span> for MacOS</li>
|
|
<li><span class="d_inlinecode donthyphenate notranslate">dragonfly</span> or <span class="d_inlinecode donthyphenate notranslate">dragonflybsd</span> for DragonflyBSD</li>
|
|
<li><span class="d_inlinecode donthyphenate notranslate">freebsd</span>, <span class="d_inlinecode donthyphenate notranslate">openbsd</span>, <span class="d_inlinecode donthyphenate notranslate">linux</span>, <span class="d_inlinecode donthyphenate notranslate">solaris</span>, <span class="d_inlinecode donthyphenate notranslate">hurd</span> or <span class="d_inlinecode donthyphenate notranslate">windows</span> for their respective operating systems</li>
|
|
</ul>
|
|
<li><i>cenv</i> is the C runtime environment and is optional:</li>
|
|
<ul> <li><span class="d_inlinecode donthyphenate notranslate">musl</span> for musl-libc</li>
|
|
<li><span class="d_inlinecode donthyphenate notranslate">msvc</span> for the MSVC runtime</li>
|
|
<li><span class="d_inlinecode donthyphenate notranslate">bionic</span> for the Android libc</li>
|
|
<li><span class="d_inlinecode donthyphenate notranslate">gnu</span> or <span class="d_inlinecode donthyphenate notranslate">glibc</span> for the GCC C runtime</li>
|
|
<li><span class="d_inlinecode donthyphenate notranslate">newlib</span> or <span class="d_inlinecode donthyphenate notranslate">uclibc</span> for their respective C runtimes</li>
|
|
</ul>
|
|
<li><i>cppenv</i> is the C++ runtime environment:</li>
|
|
<ul> <li><span class="d_inlinecode donthyphenate notranslate">clang</span> for the LLVM C++ runtime</li>
|
|
<li><span class="d_inlinecode donthyphenate notranslate">gcc</span> for GCC's C++ runtime</li>
|
|
<li><span class="d_inlinecode donthyphenate notranslate">msvc</span> for microsoft's MSVC C++ runtime</li>
|
|
<li><span class="d_inlinecode donthyphenate notranslate">sun</span> for Sun's C++ runtime</li>
|
|
</ul>
|
|
</ul>
|
|
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-transition" href="#switch-transition"><b>-transition</b></a>=<i>name</i></dt><dd>
|
|
Show additional info about language change identified by <i>name</i>
|
|
</dd><dt><b>-transition</b>=[<i>h|help|?</i>]</dt><dd>
|
|
List all language changes
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-unittest" href="#switch-unittest"><b>-unittest</b></a></dt><dd>
|
|
Compile in <a href="spec/unittest.html">unittest</a> code, turns on asserts, and sets the
|
|
<span class="d_inlinecode donthyphenate notranslate">unittest</span> <a href="spec/version.html#PredefinedVersions">version identifier</a>
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-unittest-roots" href="#switch-unittest-roots"><b>-unittest-roots</b></a></dt><dd>
|
|
Compile in <a href="spec/unittest.html">unittest</a> code, turns on asserts, and sets the
|
|
<span class="d_inlinecode donthyphenate notranslate">unittest</span> <a href="spec/version.html#PredefinedVersions">version identifier</a> only for root modules whose sources files are explicitly passed as arguments to compiler
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-v" href="#switch-v"><b>-v</b></a></dt><dd>
|
|
Enable verbose output for each compiler pass
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-vasm" href="#switch-vasm"><b>-vasm</b></a></dt><dd>
|
|
List generated assembler for each function
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-vcolumns" href="#switch-vcolumns"><b>-vcolumns</b></a></dt><dd>
|
|
Print character (column) numbers in diagnostics
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-verror-style" href="#switch-verror-style"><b>-verror-style</b></a>=[<i>digitalmars|gnu|sarif</i>]</dt><dd>
|
|
Set the style for file/line number annotations on compiler messages,
|
|
where:
|
|
<dl> <dt>digitalmars</dt><dd>'file(line[,column]): message'. This is the default.</dd>
|
|
<dt>gnu</dt><dd>'file:line[:column]: message', conforming to the GNU standard used by gcc and clang.</dd>
|
|
<dt>sarif</dt><dd>'Generates JSON output conforming to the SARIF (Static Analysis Results Interchange Format) standard, useful for integration with tools like GitHub and other SARIF readers.'</dd>
|
|
</dl>
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-verror-supplements" href="#switch-verror-supplements"><b>-verror-supplements</b></a>=<i>num</i></dt><dd>
|
|
Limit the number of supplemental messages for each error (0 means unlimited)
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-verrors" href="#switch-verrors"><b>-verrors</b></a>=<i>num</i></dt><dd>
|
|
Limit the number of error/deprecation messages (0 means unlimited)
|
|
</dd><dt><b>-verrors</b>=[<i>context|simple</i>]</dt><dd>
|
|
Set the verbosity of error messages:
|
|
<dl> <dt>context</dt><dd>Show error messages with the context of the erroring source line (including caret).</dd>
|
|
<dt>simple</dt><dd>Show error messages without the context of the erroring source line.</dd>
|
|
</dl>
|
|
</dd><dt><b>-verrors</b>=spec</dt><dd>
|
|
Show errors from speculative compiles such as <span class="d_inlinecode donthyphenate notranslate">__traits(compiles, ...)</span>
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch--version" href="#switch--version"><b>--version</b></a></dt><dd>
|
|
Print compiler version and exit
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-version" href="#switch-version"><b>-version</b></a>=<i>ident</i></dt><dd>
|
|
Compile in <a href="spec/version.html#version">version identifier</a> <i>ident</i>
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-vgc" href="#switch-vgc"><b>-vgc</b></a></dt><dd>
|
|
List all GC allocations including hidden ones
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-visibility" href="#switch-visibility"><b>-visibility</b></a>=[<i>default|hidden|public</i>]</dt><dd>
|
|
<ul> <li><i>default</i>: <i>hidden</i> for Windows targets without <a href="#switch-shared"><b>-shared</b></a>, otherwise <i>public</i></li>
|
|
<li><i>hidden</i>: Only export symbols marked with <span class="d_inlinecode donthyphenate notranslate">export</span></li>
|
|
<li><i>public</i>: Export all symbols</li>
|
|
</ul>
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-vtls" href="#switch-vtls"><b>-vtls</b></a></dt><dd>
|
|
List all variables going into thread local storage
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-vtemplates[" href="#switch-vtemplates["><b>-vtemplates[</b></a><i>=list-instances</i>]</dt><dd>
|
|
List statistics on template instantiations.
|
|
An optional argument determines extra diagnostics:
|
|
<dl> <dt>list-instances</dt><dd>Also shows all instantiation contexts for each template.</dd>
|
|
</dl>
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-w" href="#switch-w"><b>-w</b></a></dt><dd>
|
|
Enable <a href="articles/warnings.html">warnings</a>
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-wi" href="#switch-wi"><b>-wi</b></a></dt><dd>
|
|
Enable <a href="articles/warnings.html">informational warnings</a> (i.e. compilation
|
|
still proceeds normally)
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-X" href="#switch-X"><b>-X</b></a></dt><dd>
|
|
Generate JSON file
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-Xf" href="#switch-Xf"><b>-Xf</b></a>=<i>filename</i></dt><dd>
|
|
Write JSON file to <i>filename</i>
|
|
</dd><dt><a class="anchor" title="Permalink to this section" id="switch-Xcc" href="#switch-Xcc"><b>-Xcc</b></a>=<i>driverflag</i></dt><dd>
|
|
Pass <i>driverflag</i> to the linker driver (<span class="d_inlinecode donthyphenate notranslate">$CC</span> or <span class="d_inlinecode donthyphenate notranslate">cc</span>)
|
|
</dd></dl>
|
|
|
|
|
|
<p>Empty command line arguments, i.e. "", are ignored.</p>
|
|
|
|
|
|
<h2><a class="anchor" title="Permalink to this section" id="files" href="#files">Files</a></h2>
|
|
|
|
<dl>
|
|
<dt><span class="d_inlinecode donthyphenate notranslate">\dmd2\src\phobos\</span>
|
|
<dd>D runtime library source</dd>
|
|
</dt>
|
|
|
|
<dt><span class="d_inlinecode donthyphenate notranslate">\dmd2\src\dmd\</span>
|
|
<dd>D compiler front end source under dual (GPL and Artistic) license</dd>
|
|
</dt>
|
|
|
|
<dt><span class="d_inlinecode donthyphenate notranslate">\dmd2\html\d\</span>
|
|
<dd>Documentation</dd>
|
|
</dt>
|
|
|
|
|
|
<dt><span class="d_inlinecode donthyphenate notranslate">\dmd2\windows\bin\ddemangle.exe</span>
|
|
<dd>D symbol demangler</dd>
|
|
</dt>
|
|
|
|
<dt><span class="d_inlinecode donthyphenate notranslate">\dmd2\windows\bin\dmd.exe</span>
|
|
<dd>D compiler executable</dd>
|
|
</dt>
|
|
|
|
<dt><span class="d_inlinecode donthyphenate notranslate">\dmd2\windows\bin\dub.exe</span>
|
|
<dd>D's package manager</dd>
|
|
</dt>
|
|
|
|
<dt><span class="d_inlinecode donthyphenate notranslate">\dmd2\windows\bin\dustmite.exe</span>
|
|
<dd>D source code minimizer</dd>
|
|
</dt>
|
|
|
|
<dt><span class="d_inlinecode donthyphenate notranslate">\dmd2\windows\bin\rdmd.exe</span>
|
|
<dd>D build tool for script-like D code execution</dd>
|
|
</dt>
|
|
|
|
<dt><span class="d_inlinecode donthyphenate notranslate"><a href="#sc-ini">\dmd2\windows\bin\sc.ini</a></span>
|
|
<dd>Global compiler settings</dd>
|
|
</dt>
|
|
|
|
<dt><span class="d_inlinecode donthyphenate notranslate">\dmd2\windows\lib$(LIB)</span>
|
|
<dd>D runtime library</dd>
|
|
</dt>
|
|
|
|
|
|
|
|
|
|
|
|
</dl>
|
|
|
|
|
|
|
|
<h2><a class="anchor" title="Permalink to this section" id="linking" href="#linking">Linking</a></h2>
|
|
|
|
<p>Linking is done directly by the <b>dmd</b> compiler after a successful
|
|
compile. To prevent <b>dmd</b> from running the linker, use the
|
|
<a href="#switch-c"><b>-c</b></a> switch.
|
|
</p>
|
|
|
|
<p>32 bit programs must be linked with the D runtime library <b>phobos.lib</b>,
|
|
followed by the Digital Mars C runtime library <b>snn.lib</b>.
|
|
This is done automatically as long as the directories for the
|
|
libraries are on the <b>LIB</b> environment variable path. A typical
|
|
way to set <b>LIB</b> would be:
|
|
</p>
|
|
|
|
<pre class="console notranslate">set LIB=\dmd2\lib;\dm\lib
|
|
</pre>
|
|
|
|
<p>If the <b>dmd</b> command is used to both compile and link
|
|
to an executable, it will make certain optimizations that are
|
|
valid only for Windows executable files. Do not use the resulting
|
|
.obj files in a DLL.
|
|
To compile modules into .obj files that can be used in an exe or
|
|
DLL, compile with <a href="#switch-c"><b>-c</b></a> and <a href="#switch-shared"><b>-shared</b></a>.
|
|
</p>
|
|
|
|
<p>Linking 32 bit programs is done using Digital Mars <a href="http://www.digitalmars.com/ctg/optlink.html">optlink.exe</a>.
|
|
</p>
|
|
|
|
<p>Linking 64 bit programs is done using the
|
|
Microsoft linker by default. If the Microsoft linker is not found,
|
|
the included LLVM linker LLD will be used.
|
|
</p>
|
|
|
|
|
|
|
|
<h2><a class="anchor" title="Permalink to this section" id="environment" href="#environment">Environment Variables</a></h2>
|
|
|
|
<p>The D compiler dmd uses the following environment variables:
|
|
</p>
|
|
|
|
<dl>
|
|
<dt><b>DFLAGS</b></dt>
|
|
<dd>The value of <b>DFLAGS</b> is treated as if it were appended to the
|
|
command line to <b>dmd.exe</b>.</dd>
|
|
|
|
<dt><b>LIB</b></dt>
|
|
<dd>The linker uses <b>LIB</b> to search for library files. For D, it will
|
|
normally be set to:</dd>
|
|
|
|
<pre class="console notranslate">set LIB=\dmd2\lib;\dm\lib
|
|
</pre>
|
|
|
|
<dt><b>LINKCMD</b></dt>
|
|
<dd><b>dmd</b> normally runs the linker by looking for <a href="http://www.digitalmars.com/ctg/optlink.html">optlink.exe</a>
|
|
along the <b>PATH</b>. To use a specific linker for 32 bit programs instead, set the
|
|
<b>LINKCMD</b> environment variable to it. For example:</dd>
|
|
|
|
<pre class="console notranslate">set LINKCMD=\dmd\windows\bin\link
|
|
</pre>
|
|
|
|
<dt><b>LINKCMD64</b></dt>
|
|
<dd><b>dmd</b> normally runs the linker by looking for <a href="http://www.digitalmars.com/ctg/optlink.html">optlink.exe</a>
|
|
along the <b>PATH</b>. To use a specific linker for 64 bit programs instead, set the
|
|
<b>LINKCMD64</b> environment variable to it. For example:</dd>
|
|
|
|
<pre class="console notranslate">set LINKCMD64=C:\Program Files (x86)\Microsoft Visual Studio 15.0\VC\bin\amd64\link.exe
|
|
</pre>
|
|
|
|
<dt><b>PATH</b></dt>
|
|
<dd>If the linker is not found in the same directory as <b>dmd.exe</b>
|
|
is in, the <b>PATH</b> is searched for it.
|
|
<b>Note:</b> other linkers named
|
|
<b>link.exe</b> will likely not work.
|
|
Make sure the Digital Mars <a href="http://www.digitalmars.com/ctg/optlink.html">optlink.exe</a>
|
|
is found first in the <b>PATH</b> before other <b>link.exe</b>s,
|
|
or use <b>LINKCMD</b> to specifically identify which linker
|
|
to use.</dd>
|
|
|
|
|
|
</dl>
|
|
|
|
<h2><span id="sc_ini"><a class="anchor" title="Permalink to this section" id="sc-ini" href="#sc-ini">sc.ini Initialization File</a></span></h2>
|
|
|
|
<p><b>dmd</b> will look for the initialization file <b>sc.ini</b> in the
|
|
following sequence of directories:
|
|
</p>
|
|
|
|
<ol> <li>current working directory</li>
|
|
<li>directory specified by the <b>HOME</b> environment variable</li>
|
|
<li>directory <b>dmd.exe</b> resides in</li>
|
|
</ol>
|
|
|
|
<p>If found, environment variable
|
|
settings in the file will override any existing settings.
|
|
This is handy to make <b>dmd</b> independent of programs with
|
|
conflicting use of environment variables.
|
|
</p>
|
|
|
|
<h3>Initialization File Format</h3>
|
|
|
|
<p>Comments are lines that begin with <span class="d_inlinecode donthyphenate notranslate">;</span> and are ignored.
|
|
</p>
|
|
|
|
<p>Environment variables follow the <span class="d_inlinecode donthyphenate notranslate">[Environment]</span> section
|
|
heading, in <i>NAME</i>=<i>value</i> pairs.
|
|
The <i>NAME</i>s are treated as upper case.
|
|
Comments are lines that start with ;.
|
|
For example:
|
|
</p>
|
|
|
|
<pre class="scini notranslate">; sc.ini file for dmd
|
|
; Names enclosed by %% are searched for in the existing environment
|
|
; and inserted. The special name %@P% is replaced with the path
|
|
; to this file.
|
|
[Environment]
|
|
LIB="%@P%..\lib";\dm\lib
|
|
|
|
DFLAGS="-I%@P%..\src\phobos" "-I%@P%..\src\druntime\import"
|
|
LINKCMD="%@P%....\dm\bin"
|
|
DDOCFILE=mysettings.ddoc
|
|
</pre>
|
|
|
|
<h3>Location Independence of sc.ini</h3>
|
|
|
|
<p>The <b>%@P%</b> is replaced with the path to <span class="d_inlinecode donthyphenate notranslate">sc.ini</span>.
|
|
Thus, if the fully qualified file name <span class="d_inlinecode donthyphenate notranslate">sc.ini</span> is
|
|
<span class="d_inlinecode donthyphenate notranslate">c:\dmd2\bin\sc.ini</span>, then <b>%@P%</b> will be replaced with
|
|
<span class="d_inlinecode donthyphenate notranslate">c:\dmd2\bin</span>, and the above <span class="d_inlinecode donthyphenate notranslate">sc.ini</span> will be
|
|
interpreted as:
|
|
</p>
|
|
|
|
<pre class="scini notranslate">[Environment]
|
|
LIB="c:\dmd2\bin..\lib";\dm\lib
|
|
|
|
DFLAGS="-Ic:\dmd2\bin..\src\phobos" "-Ic:\dmd2\bin..\src\druntime\import"
|
|
LINKCMD="c:\dmd2\bin....\dm\bin"
|
|
DDOCFILE=mysettings.ddoc
|
|
</pre>
|
|
|
|
<p>This enables your dmd setup to be moved around without having
|
|
to re-edit <span class="d_inlinecode donthyphenate notranslate">sc.ini</span>.
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<h2><a class="anchor" title="Permalink to this section" id="problems" href="#problems">Common Installation Problems</a></h2>
|
|
|
|
<ul> <li>Using Cygwin's <b>unzip</b> utility has been known to cause
|
|
strange problems.
|
|
</li>
|
|
<li>Running the compiler under Cygwin's command shell has
|
|
been also known to cause problems. Try getting it to work
|
|
under the regular Windows shell <b>cmd.exe</b> before trying Cygwin's.
|
|
</li>
|
|
<li>Installing <b>dmd</b> and <b><a href="http://www.digitalmars.com/ctg/sc.html">dmc</a></b> into directory paths with spaces
|
|
in them causes problems.
|
|
</li>
|
|
</ul>
|
|
|
|
|
|
<hr>
|
|
<h2><a class="anchor" title="Permalink to this section" id="differences" href="#differences">Differences between Windows and Linux versions</a></h2>
|
|
|
|
<ul> <li>String literals are read-only under Linux.
|
|
Attempting to write to them
|
|
will cause a segment violation.</li>
|
|
</ul>
|
|
<hr>
|
|
<h2><span id="interface_files"><a class="anchor" title="Permalink to this section" id="interface-files" href="#interface-files">D Interface Files</a></span></h2>
|
|
|
|
<p>When an import declaration is processed in a D source file,
|
|
the compiler searches for the D source file corresponding to
|
|
the import, and processes that source file to extract the
|
|
information needed from it. Alternatively, the compiler can
|
|
instead look for a corresponding <i>D interface file</i>.
|
|
A D interface file contains only what an import of the module
|
|
needs, rather than the whole implementation of that module.
|
|
</p>
|
|
|
|
<p>The advantages of using a D interface file for imports rather
|
|
than a D source file are:
|
|
</p>
|
|
|
|
<ul> <li>D interface files are often significantly smaller and much
|
|
faster to process than the corresponding D source file.</li>
|
|
<li>They can be used to hide the source code, for example,
|
|
one can ship an object code library along with D interface files
|
|
rather than the complete source code.</li>
|
|
</ul>
|
|
|
|
<p>D interface files can be created by the compiler from a
|
|
D source file by using the <a href="#switch-H"><b>-H</b></a> switch to the compiler.
|
|
D interface files have the <b>.di</b> file extension.
|
|
When the compiler resolves an import declaration, it first looks
|
|
for a <b>.di</b> D interface file, then it looks for a D source
|
|
file.
|
|
</p>
|
|
|
|
<p>D interface files bear some analogous similarities to C++
|
|
header files. But they are not required in the way that C++
|
|
header files are, and they are not part of the D language.
|
|
They are a feature of the compiler, and serve only as an optimization
|
|
of the build process.
|
|
</p>
|
|
|
|
<h2><a class="anchor" title="Permalink to this section" id="executable" href="#executable">Building Executables</a></h2>
|
|
|
|
<p><b>dmd</b> can build an executable much faster if as many of the
|
|
source files as possible are put on the command line.</p>
|
|
|
|
<p>Another advantage to putting multiple source files on the same
|
|
invocation of <b>dmd</b> is that <b>dmd</b> will be able to do some level
|
|
of cross-module optimizations, such as function inlining across modules.
|
|
</p>
|
|
<p>The <span class="d_inlinecode donthyphenate notranslate">-i</span> flag can be used to automatically compile imported modules</p>
|
|
|
|
<h2><a class="anchor" title="Permalink to this section" id="library" href="#library">Building Libraries</a></h2>
|
|
|
|
<p>There are three ways to build a library. For example,
|
|
given <span class="d_inlinecode donthyphenate notranslate">foo.d</span> and <span class="d_inlinecode donthyphenate notranslate">bar.d</span> which are to be compiled, and existing
|
|
object file <span class="d_inlinecode donthyphenate notranslate">abc.obj</span> and existing library
|
|
<span class="d_inlinecode donthyphenate notranslate">def.lib</span> which are
|
|
all to be combined into a library <span class="d_inlinecode donthyphenate notranslate">foo.lib</span>:</p>
|
|
|
|
<ol> <li>Compile modules separately and then run the librarian on them:
|
|
<pre class="console notranslate">dmd -c foo.d
|
|
dmd -c bar.d
|
|
phobos.lib -c -p32 foo.lib foo.obj bar.obj abc.obj def.lib
|
|
del foo.obj bar.obj
|
|
</pre>
|
|
|
|
|
|
This option is typical when using a makefile to avoid compiling
|
|
modules that have already been compiled.
|
|
</li>
|
|
<li>Compile modules together and then run the librarian on them:
|
|
<pre class="console notranslate">dmd -c foo.d bar.d
|
|
phobos.lib -c -p32 foo.lib foo.obj bar.obj abc.obj def.lib
|
|
del foo.obj bar.obj
|
|
</pre>
|
|
|
|
|
|
</li>
|
|
<li>Use <b>dmd</b> to compile and build library in one operation:
|
|
<pre class="console notranslate">dmd -lib foo.d bar.d abc.obj def.lib
|
|
</pre>
|
|
No object files are written to disk, it's all done in memory.
|
|
Using <a href="#switch-lib"><b>-lib</b></a> also has the advantage that modules may be compiled
|
|
into multiple object files rather than exactly one per module.
|
|
This improves granularity of the library without having to break
|
|
up the modules.
|
|
</li>
|
|
</ol>
|
|
)
|
|
|
|
|
|
<div class="smallprint" id="copyright">Copyright © 1999-2026 by the <a href="foundation_overview.html">D Language Foundation</a> | Page generated by
|
|
<a href="spec/ddoc.html">Ddoc</a> on Mon Oct 26 00:46:27 2026
|
|
|