View previous topic :: View next topic |
Author |
Message |
alyan
Joined: 10 Jul 2007 Posts: 7
|
Posted: Wed Jul 11, 2007 1:00 am Post subject: Ported derelict to DMD 2.0... |
|
|
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.
Download it here:
http://homepages.dcc.ufmg.br/~blizzard/trunk-r266-D2.0.tar.bz2
Best Regars,
Daniel |
|
Back to top |
|
|
baxissimo
Joined: 23 Oct 2006 Posts: 241 Location: Tokyo, Japan
|
Posted: Tue Aug 28, 2007 4:05 pm Post subject: Nice work! |
|
|
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 |
|
|
aldacron
Joined: 05 May 2004 Posts: 1322 Location: Seoul, South Korea
|
Posted: Tue Aug 28, 2007 5:56 pm Post subject: |
|
|
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 |
|
|
baxissimo
Joined: 23 Oct 2006 Posts: 241 Location: Tokyo, Japan
|
Posted: Tue Aug 28, 2007 6:50 pm Post subject: |
|
|
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 |
|
|
alyan
Joined: 10 Jul 2007 Posts: 7
|
Posted: Wed Sep 12, 2007 9:26 am Post subject: |
|
|
* 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 |
|
|
baxissimo
Joined: 23 Oct 2006 Posts: 241 Location: Tokyo, Japan
|
Posted: Wed Sep 12, 2007 2:57 pm Post subject: |
|
|
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 |
|
|
alyan
Joined: 10 Jul 2007 Posts: 7
|
Posted: Wed Sep 19, 2007 1:20 pm Post subject: |
|
|
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 |
|
|
div0
Joined: 10 Sep 2007 Posts: 19 Location: tedium city, uk
|
Posted: Wed Sep 19, 2007 1:57 pm Post subject: |
|
|
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 |
|
|
alyan
Joined: 10 Jul 2007 Posts: 7
|
Posted: Wed Sep 26, 2007 9:05 am Post subject: |
|
|
Hmm... You're right indeed. My mistake. Still... I'm not sure how to do this. |
|
Back to top |
|
|
QueChatosComRegistos
Joined: 23 Nov 2006 Posts: 16
|
Posted: Tue Oct 02, 2007 12:05 pm Post subject: Compile error |
|
|
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 |
|
|
aldacron
Joined: 05 May 2004 Posts: 1322 Location: Seoul, South Korea
|
Posted: Tue Oct 02, 2007 2:19 pm Post subject: |
|
|
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 |
|
|
|