A few weeks ago, I messed around with dmd (the original compiler for the D programming language).
Well, here’s a bit of info about gdc, a D language front end for gcc.
I couldn’t find a package in the Ubuntu repositories, so I downloaded a Linux binary and installed it:
$ wget http://umn.dl.sourceforge.net/sourceforge/dgcc/gdc-0.22-i686-linux-gcc-4.1.1.tar.bz2
$ tzx gdc-0.22-i686-linux-gcc-4.1.1.tar.bz2
$ cd gdc
$ cd bin
$ sudo cp * /usr/local/bin/
$ cd ../lib
$ sudo cp -r * /usr/lib
$ cd ../include
$ sudo cp -r d /usr/include
$ cd ../libexec
$ sudo cp -r * /usr/lib
$ gdc -I/usr/include/d/4.1.1 hello.d -o hello
$ ./hello
$ ./hello
hello world
args.length = 1
args[0] = ‘./hello’
Here’s the program I used:
$ cat hello.d
int main(char[][] args)
{
printf(”hello world\n”);
printf(”args.length = %d\n”, args.length);
for (int i = 0; i < args.length; i++)
printf("args[%d] = '%s'\n", i, cast(char *)args[i]);
return 0;
}
or
marc@tbird:~/sw/gdc$ cat hello.d
import std.stdio;
int main(char[][] args)
{
printf(”hello world\n”);
printf(”args.length = %d\n”, args.length);
for (int i = 0; i < args.length; i++)
writefln("args[%d] = '%s'\n", i, args[i]);
return 0;
}
but for the latter, I needed to modify the compile command:
$ gdc -I/usr/include/d/4.1.1 -I/usr/include/d/4.1.1/i686-pc-linux-gnu hello.d -o hello
(It would be nice to build and install from the source code - my guess is that would eliminate those ugly -I options).
Popularity: 7% [?]