Last update December 23, 2008

Doc Comments /

D Compiler    

Table of contents of this page
D Compiler   
"-debug", "-release", both and neither   
Convert C .h files into D imports   
Installation notes for Linux   
Undocumented debug switches   
The -I switch   
Linux Version   
-profile (formerly known as -gt) switch   
Response files   
Questions and Answers   


"-debug", "-release", both and neither    

DerekParnell November 3, 2006 4:10 CET
The -release and -debug are totally independant from each other. "-release" prevents DbC and asserts from being compiled in. "-debug" allows debug statements to be compiled in. Note that "-debug" is the same functionality as "-version" but it uses a different word so the coder can communicate their intention for the conditionally compiled code.
Note that these two fragments are functionally identical. The only difference is the reason that the coder is trying to tell any readers of the code.
  debug(xyz) writefln("Some information");
  version(xyz) writefln("Some information");

There are four variants:
  1. "-release -debug" Causes DbC and assert code to be excluded and causes debug statements to be included.
  2. "-release" Causes DbC and assert code to be excluded and causes debug statements to be excluded.
  3. "-debug" Causes DbC and assert code to be included and causes debug statements to be included.
  4. (nothing) Causes DbC and assert code to be included and causes debug statements to be excluded.
And note that unit tests are only compiled in if the "-unittest" switch is used and this is independant of both "-release" and "-debug".

Convert C .h files into D imports    

"Need to write a tool to convert C .h files into D imports."

Isn't htod such a tool?

  • Sure, but DM "htod" is also Windows-only...
I wonder if the h2d project on dsource ( forum, download) is of any use to Linux users. It's been around for a while (and I don't think it's been updated recently), but maybe it's still relevant.

Installation notes for Linux    

  1. If you are copying the files to /usr/local/bin, you need to change to that directory, and as super-user, give execute permissions to the files under /usr/local/bin.

Undocumented debug switches    

  • --b
  • --c
  • --f
  • --r
  • --x
  • --y
-- ThomasKühne

The -I switch    

The docs say that multiple paths can be delimited using the ';' character, however it appears that this only applies to Windows. For linux (unix?) you need to use the ':' instead.




-- DerekParnell

Linux Version    

(from NG:digitalmars.D/33123 by Nick)

For the linux version, it says that -I takes a ';' separated list. It doesn't, it takes a ':' separated list. Also (further down), the example dmd.conf file is wrong. It suggests the line

The slashes should be forward slashes, and does the %@P% syntax even work in the linux version?

-profile (formerly known as -gt) switch    

I think the -gt flag is useful. The primary feedback output ends up in the 'trace.log' file.

It's more than useful. Ever wonder why DMC++ has held the speed record for compilation speed for the last 15 years? Why DMDScript is twice as fast as jscript? If you want to make your app sing, -gt is the answer. <g>

P.S. I wrote -gt because existing profilers at the time were notoriously difficult to use. Most required one to slog through a 50 page manual to figure out how to use, and there was a lot of work involved in setting things up. As a consequence, nobody used profilers. I wanted one that was as simple as throwing a command line switch. -gt succeeds in that, but it's still rare for anyone to use it. I'm at a loss as to why. Sometimes I wonder if the reason is because people overlook it thinking "it can't be that easy" because they are still accustomed to profilers being a big fat pain to learn how to use and apply.

P.P.S. -gt is not a terribly sophisticated profiler, but I've used it extensively and it gets the job done.

Adapted from NG:digitalmars.D/20040

With DMD 0.120, the -gt switch was renamed to -profile.

Related newsgroup post: -profile output: Walter's profiler tips

Response files    

Someone gave me the hint that all Digital Mars tools (in this case dmd) may be passed a response file containing the parameters that would otherwise be passed using the commandline. I tested this with a small example (under Windows) and it seems to work. E. g. instead of

   dmd -v test foo
one may write
   dmd @test.rsp
with test.rsp containing
   -v test foo
in a single line or
in separate lines. I think this should be noted in the official documentation (it is more important and intuitive to Windows users, because the command line is very restricted in length compared to Linux; it is not intuitive to Linux users because various tools use different methods to bypass commandline restrictions and @responsefile is not as common). -- HelmutLeitner

  • Linux (and other sane shells) have other means to do it: cat test.rsp | xargs dmd
or even faster: dmd `cat test.rsp` -- MaximilianHasler?, 18.7.06

Questions and Answers    

Questions (

  1. Downloading compilers is problematic and not successful always. Please check and correct.
  2. Will D language replace C++, C#, Java?
  3. Development support for web based solutions like EJB, etc. is not mentioned.
  4. Yes, D for Linux. But what library versions are needed?
I.e. I might have a very old Linux, possibly with self-upgraded libraries, or then I might have a (somewhat) recent Public Distro. So: how do I know whether the latest D works on them????

Answers (JustinCalvarese)

  1. It works for me when I try. Could it be a problem with your connection?
  2. I'd like to see D replace all three, but it probably won't any time soon.
  3. Sounds like you may be interested in something like DSP: "A dynamic servlet generation toolkit, designed for web servers"
Answers (
  1. It will be easier when packages for deb and rpm and available. See if your linux distro has gdc yet.
  2. I'd like to see D replace C++, but not Java. Virtual machine systems are nice for many applications (non CPU intensive, e.g. business operations and accounting) because binaries can be copied between disparate systems. I know gcj compiles Java to native - but Java isn't actually that great a language for native code. The Java virtual machine efficiently enforces a powerful language level security model. C++ is powerful, but big, messy, and inelegant. D keeps all the power, including template metaprogramming, without the mess.


FrontPage | News | TestPage | MessageBoard | Search | Contributors | Folders | Index | Help | Preferences | Edit

Edit text of this page (date of last change: December 23, 2008 15:51 (diff))