Doc Comments /
DCompiler
D Compiler
Comments
"-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");
- and
version(xyz) writefln("Some information");
- There are four variants:
- "-release -debug" Causes DbC and assert code to be excluded and causes debug statements to be included.
- "-release" Causes DbC and assert code to be excluded and causes debug statements to be excluded.
- "-debug" Causes DbC and assert code to be included and causes debug statements to be included.
- (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...
Installation notes for Linux
- 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
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.
Windows
-I%@P%\..\src\phobos;C:\DLibsUnix
-I%@P%/../src/phobos:/usr/DLibs-- 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
DFLAGS="-I%@P%\..\src\phobos"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.
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 fooone may write
dmd @test.rspwith test.rsp containing
-v test fooin a single line or
-v test fooin 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 (rajensraut@yahoo.com)
- Downloading compilers is problematic and not successful always. Please check and correct.
- Will D language replace C++, C#, Java?
- Development support for web based solutions like EJB, etc. is not mentioned.
- Yes, D for Linux. But what library versions are needed?
Answers (JustinCalvarese)
- It works for me when I try. Could it be a problem with your connection?
- I'd like to see D replace all three, but it probably won't any time soon.
- Sounds like you may be interested in something like DSP: "A dynamic servlet generation toolkit, designed for web servers"
- It will be easier when packages for deb and rpm and available. See if your linux distro has gdc yet.
- 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.
Links
- Corresponding page in the D Specification:
- More installation instructions: Installing D Compiler
- Linux installation tips
- RPM packages for DMD:
- NG:digitalmars.D/13575 (DMD 0.109)
- NG:digitalmars.D/21826 (DMD 0.121)
- NG:digitalmars.D/46451 (DMD 1.00)