View Full Version : D compiler not working
cl333r
30th September 2010, 04:53 PM
Hi,
Afaik I'm supposed to use "ldc" to compile D source code, so I'm running x64 F14 beta
and when I do:
ldc test.d
I get:
object.d: Error: module object cannot read file 'object.d'
import path[0] = /usr/include/d/
import path[1] = /usr/include/d/tango
import path[2] = /usr/include/d/tango/core/vendor
File "test.d" is in home dir and is supposed to just print "hello world".
import std.stdio;
int main() {
writeln("hello world");
return 0;
}
Using "writefln" doesn't change the issue.
Anyone knows what's up?
bioinfornatics
1st October 2010, 01:37 AM
D compiler use Tango instead Phobos because tango is better for D1
2 way:
First C style
import tango.stdc.stdio;
int main() {
printf("hello world");
return 0;
}
2nd Tango Style
import tango.io.Stdout;
int main() {
Stdout("hello world");
return 0;
}
cl333r
1st October 2010, 02:02 PM
Thanks, after I installed tango-devel (I hoped it installed with the D compiler) your examples started working, though mine still doesn't.
D'you happen to know when D2 might land into Fedora? Any hope for next year? I got a book on D2, which is quite different from D1...
bioinfornatics
1st October 2010, 02:34 PM
the problem is:
I can not package dmd compiler because the backend is not free
I gdc is not a gcc project and is less up to date as ldc
ldc works only for D1, they are an experimental branch for D2 but if some c++ developper want help this project :D you are welcome .
ldc make a faster executable as dmd for d1
you can try this code with ldc and dmd
version(Tango){
import tango.stdc.stdio: printf;
}
else{
import std.c.stdio: printf;
}
int NLOOPS = 100000;
int c1, c2, c3;
void f1() { c1++; }
void f2() { c2++; }
void f3() { c3++; }
int main() {
int i, j;
for (i = 0; i < NLOOPS; i++) {
for (j = 0; j < 5000; j++) {
switch (j) {
case 140: f1(); break;
case 300: f1(); break;
case 1280: f1(); break;
case 1540: f1(); break;
case 1660: f1(); break;
case 1770: f2(); break;
case 2150: f2(); break;
case 2190: f1(); break;
case 2530: f2(); break;
case 2560: f2(); break;
case 2590: f1(); break;
case 2660: f1(); break;
case 2720: f2(); break;
case 3010: f1(); break;
case 3100: f1(); break;
case 3390: f2(); break;
case 3760: f1(); break;
case 3970: f2(); break;
case 4050: f1(); break;
case 4140: f1(); break;
case 4360: f2(); break;
case 4540: f1(); break;
case 4600: f2(); break;
case 4720: f2(); break;
case 4730: f2(); break;
case 4740: f2(); break;
case 4880: f2(); break;
case 4950: f1(); break;
default: f3();
}
}
}
printf("%d %d %d\n", c1, c2, c3);
return 0;
}
compile it and run
$ time ./test
They are some D example here (http://blog.fedora-fr.org/bioinfornatics/category/Progammation/Langage/D)
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.