FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Ported derelict to DMD 2.0...

 
Post new topic   Reply to topic     Forum Index -> Derelict
View previous topic :: View next topic  
Author Message
alyan



Joined: 10 Jul 2007
Posts: 7

PostPosted: Wed Jul 11, 2007 1:00 am    Post subject: Ported derelict to DMD 2.0... Reply with quote

I ported Derelict r266 to version 2.002.
If you are in a hurry, download roll down and download it.

Basically I unpacked trunk-r266.zip and...

- Global Search and Replace char[] for string

$ sed -i s/char\\[\\]/string/g $(find | grep \\.d)

- Edit buildopts/bud_common.txt and remove '-v1' line (without quotes)

- Edit line 90 of DerelictODE/derelict/ode/odemath.d, change first parameter type from 'in dReal*A' to 'inout dReal*A' (apparently a bug!)

** UPDATE **

- DerelictSDL's audio.d (line 112) video.d (lines 205 and 210) use string literals when char* are expected. Since literals are null terminated, just cast them to char*.

cast(char*)"literal"

** END UPDATE **

- In DerelictGL's gl.d, line 288:
static char vstrings[GLVersion.max + 1][] = [GLVersion.VersionNone:"Unknown",
to
static string vstrings[GLVersion.max + 1] = [GLVersion.VersionNone:"Unknown",

And it builds. Apparently thats it.

** UPDATE **

Tested and it builds on version 1.018 also. Pehaps you guys could merge the changes on Derelict's official source tree so we can use it on both DMD 1 and 2. Smile

Download it here:

http://homepages.dcc.ufmg.br/~blizzard/trunk-r266-D2.0.tar.bz2

Best Regars,
Daniel
Back to top
View user's profile Send private message
baxissimo



Joined: 23 Oct 2006
Posts: 241
Location: Tokyo, Japan

PostPosted: Tue Aug 28, 2007 4:05 pm    Post subject: Nice work! Reply with quote

Ooh yes, I hope you guys can find some time to review & merge Alyan's patch.

I'm actually quite surprised this hasn't gotten any reply in the month and a half it's been posted. I'd like to start trying to make my code work with 2.0, but I can't really start trying to until Derelict and other dependencies are 2.0-ified. I'm sure a lot of folks are in the same boat.
Back to top
View user's profile Send private message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Tue Aug 28, 2007 5:56 pm    Post subject: Reply with quote

I've mentioned elsewhere in the forum that I have no plans to make any changes for 2.0 until it is near to release.
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
baxissimo



Joined: 23 Oct 2006
Posts: 241
Location: Tokyo, Japan

PostPosted: Tue Aug 28, 2007 6:50 pm    Post subject: Reply with quote

aldacron wrote:
I've mentioned elsewhere in the forum that I have no plans to make any changes for 2.0 until it is near to release.


Ah, ok. I took the 2.0 comment to mean you just didn't intend to do it yourself. Not that you wouldn't be accepting patches from others along those lines.

--bb
Back to top
View user's profile Send private message
alyan



Joined: 10 Jul 2007
Posts: 7

PostPosted: Wed Sep 12, 2007 9:26 am    Post subject: Reply with quote

* EDIT: This is not really necessary since D string literals are indeed null terminated. *

I made a mistake on converting D string literals to C strings.

cast(char*)"literal"

should be:

toStringz("literal")

The first version will most likely crash.

best,

Daniel


Last edited by alyan on Wed Sep 26, 2007 9:07 am; edited 1 time in total
Back to top
View user's profile Send private message
baxissimo



Joined: 23 Oct 2006
Posts: 241
Location: Tokyo, Japan

PostPosted: Wed Sep 12, 2007 2:57 pm    Post subject: Reply with quote

alyan wrote:
I made a mistake on converting D string literals to C strings.

cast(char*)"literal"

should be:

toStringz("literal")

The first version will most likely crash.

best,

Daniel


I thought I heard somewhere that D string literals actually do have a terminating null character, so that casting those to char* was ok. ... or at least casting the pointer: cast(char*)"literal".ptr .
Back to top
View user's profile Send private message
alyan



Joined: 10 Jul 2007
Posts: 7

PostPosted: Wed Sep 19, 2007 1:20 pm    Post subject: Reply with quote

Actually, they don't. At least not in version 2.0. Strings are simply char[]. Arrays are not null terminated.


char* toStringz(const char[] s);
Convert array of chars s[] to a C-style 0 terminated string.

Best regards,
Daniel
Back to top
View user's profile Send private message
div0



Joined: 10 Sep 2007
Posts: 19
Location: tedium city, uk

PostPosted: Wed Sep 19, 2007 1:57 pm    Post subject: Reply with quote

alyan wrote:
Actually, they don't. At least not in version 2.0. Strings are simply char[]. Arrays are not null terminated.


char* toStringz(const char[] s);
Convert array of chars s[] to a C-style 0 terminated string.

Best regards,
Daniel


No he was right, according to da man:

http://www.digitalmars.com/d/interfaceToC.html

String literals are 0 terminated. Run time constructed strings are not

Whether it's explicitly stated enough in the language spec for you to want to rely on that behavior is a another matter...
It's kinda just mentioned in passing, so it's probably best to avoid if you want to be absolutely sure your code is going to work with any D compiler.
Back to top
View user's profile Send private message
alyan



Joined: 10 Jul 2007
Posts: 7

PostPosted: Wed Sep 26, 2007 9:05 am    Post subject: Reply with quote

Hmm... You're right indeed. My mistake. Still... I'm not sure how to do this.
Back to top
View user's profile Send private message
QueChatosComRegistos



Joined: 23 Nov 2006
Posts: 16

PostPosted: Tue Oct 02, 2007 12:05 pm    Post subject: Compile error Reply with quote

I just switched to DMD 2.004 and derelict doesn't compile. The error follows:

Code:

derelict\util\loader.d(222): Error: cannot implicitly convert expression ("") of type invariant char[0u] to char[]
Stack overflow


obviously it's something I am doing wrong because as far as I know, no-one has the same problem.
Btw, I'm compiling derelict along my program, not linking. I'm using OpenGL, SDL and Devil.
Back to top
View user's profile Send private message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Tue Oct 02, 2007 2:19 pm    Post subject: Reply with quote

Are you using the source from the trunk or alyan's modified version? If the former, then your problem is that it does not support D 2.0.
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Derelict All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group