Re: strlen, strcpy, etc errors when trying to link an object
On Sun, 01 Feb 2015 18:34:01 +, irtcupc wrote: did you build BeaEngine with dmc? if not, try to rebuild with dmc compiler. signature.asc Description: PGP signature
Re: windows wininet library
On Sun, 01 Feb 2015 17:54:50 +0100, Benjamin Thaut wrote: > Am 01.02.2015 um 17:15 schrieb ketmar: >> On Sun, 01 Feb 2015 16:07:58 +, John Chapman wrote: >> >>> On Sunday, 1 February 2015 at 08:37:23 UTC, ketmar wrote: seems that my idea of using D to write a simple windows utility was very wrong. ok, another attempt to use D for our windows developement has failed. i'm in no way can sell manual ".def" creation to our team -- they will make fun of me, showing how their Visual C can compile this code without any troubles and external utilities... >>> >>> It's easier to run coffimplib on the lib files from the Windows SDK. >> >> sorry if i'm rude, i really appreciate your advice. i messed myself >> thinking that this is another thread in "general" NG. >> >> > The Windows SDK can be downloaded seperately from visual studio: > https://msdn.microsoft.com/en-us/windows/desktop/ff851942.aspx > > They are also backwards compatible, so the latest one should work on XP. > But you can also just use the oldest one available to make sure it still > works on your machine. thank you. maybe this should be documented somehow -- page in Wiki, perhaps, so people trying to find various import libraries can be pointed there? signature.asc Description: PGP signature
Re: Conway's game of life
On Sunday, 1 February 2015 at 21:00:07 UTC, gedaiu wrote: Hi, I implemented Conway's game of life in D. What do you think that I can improve to this program to take advantage of more D features? https://github.com/gedaiu/Game-Of-Life-D Thanks, Bogdan If the subject of the game "Life" is interesting to you, look at these links: http://en.wikipedia.org/wiki/Hashlife http://golly.sourceforge.net
Re: Conway's game of life
On 2015-02-01 at 22:00, gedaiu wrote: I implemented Conway's game of life in D. I think you are playing a different game here. /// Count cell neighbours long neighbours(Cell myCell, CellList list) { long cnt; foreach(cell; list) { auto diff1 = abs(myCell.x - cell.x); auto diff2 = abs(myCell.y - cell.y); if(diff1 == 1 || diff2 == 1) cnt++; // Why || instead of && ??? } return cnt; }
Re: Can't understand how to compare DateTime with opCmp
On Sunday, February 01, 2015 19:22:40 Suliman via Digitalmars-d-learn wrote: > "+ n.days" solved my problem. Roll is specifically for cases where you want one of the fields to increase or decrease without affecting the others (e.g. if you had a spin control in your GUI with a DateTime backing it and didn't want any units other than the currently altered unit to change when its value wrapped around). In most cases, you're simply going to want to add a Duration to it - which dt + days(n) or dt + n.days will do. - Jonathan M Davis
Re: Conway's game of life
On Sunday, 1 February 2015 at 21:00:07 UTC, gedaiu wrote: Hi, I implemented Conway's game of life in D. What do you think that I can improve to this program to take advantage of more D features? https://github.com/gedaiu/Game-Of-Life-D Thanks, Bogdan For each remove you create a new array. That is lavish. You should use a bool inside the struct Cell. If it's false, the cell is not displayed and is out of the game. My suggestion: don't use the D GC, it's crap. Try to circumvent the GC wherever possible. Therefore you should use the -vgc compiler flag and the @nogc attribute.
Re: Conway's game of life
1. I prefer alias CellList = Cell[]; over alias Cell[] CellList; 2. Do you really need to create a complete new CellList for every single removal? If so, you'd know the size of the new list in advance and can allocate it directly at the correct size. I get the impression that you think Cell[] is a linked list but it's an array slice.
Re: how convert the range to slice ?
On Wednesday, 28 January 2015 at 23:21:34 UTC, Nordlöw wrote: I'll dig into it later on... Is started digging a bit... The magic happens at line 103 in cast.c. How do I most conveniently figure out which members (functions) a type (e->type) has? I figured I could check for typical InputRange members and issue a hint about using .array if e->type has them.
Conway's game of life
Hi, I implemented Conway's game of life in D. What do you think that I can improve to this program to take advantage of more D features? https://github.com/gedaiu/Game-Of-Life-D Thanks, Bogdan
Re: Can't understand how to compare DateTime with opCmp
"+ n.days" solved my problem.
Re: strlen, strcpy, etc errors when trying to link an object
On Sunday, 1 February 2015 at 18:19:54 UTC, irtcupc wrote: Hello, I try to link an object file under win32, the format is ok (omf), i haven't yet started to write the di interface (it exists in a c H file that i'll translate) that a simple compilation try gives me: --- C:\...\myObj.obj(myObj) Error 42: Symbol Undefined strlen C:\...\myObj.obj(myObj) Error 42: Symbol Undefined strcpy C:\...\myObj.obj(myObj) Error 42: Symbol Undefined strcmp C:\...\myObj.obj(myObj) Error 42: Symbol Undefined memset C:\...\myObj.obj(myObj) Error 42: Symbol Undefined sprintf --- It looks like the object wants some things coming from snn... the command line looks like: --- dmd app.d myObj.di myObj.obj --- How can i "tell" the obj to use the matching snn function ? No reason not to be more accurate: http://www.beaengine.org/downloads 1/ get the win32 zip file. 2/ the folder \Win32\Delphi contains the OMF object (Delphi doesnt matter here, the gui has called to folder like this because he thought Delphi is the only compilo to still use OMF ;) ) 3/ simply try to link with a dummy d source containing a main() dmd dummy.d BeaEngineLib.obj A few years ago i used it in a Pascal app and i could define the involved functions but here, dmd will complain about ... Error 1: Previous Definition Different : _strlen
strlen, strcpy, etc errors when trying to link an object
Hello, I try to link an object file under win32, the format is ok (omf), i haven't yet started to write the di interface (it exists in a c H file that i'll translate) that a simple compilation try gives me: --- C:\...\myObj.obj(myObj) Error 42: Symbol Undefined strlen C:\...\myObj.obj(myObj) Error 42: Symbol Undefined strcpy C:\...\myObj.obj(myObj) Error 42: Symbol Undefined strcmp C:\...\myObj.obj(myObj) Error 42: Symbol Undefined memset C:\...\myObj.obj(myObj) Error 42: Symbol Undefined sprintf --- It looks like the object wants some things coming from snn... the command line looks like: --- dmd app.d myObj.di myObj.obj --- How can i "tell" the obj to use the matching snn function ?
Re: windows wininet library
Am 01.02.2015 um 17:15 schrieb ketmar: On Sun, 01 Feb 2015 16:07:58 +, John Chapman wrote: On Sunday, 1 February 2015 at 08:37:23 UTC, ketmar wrote: seems that my idea of using D to write a simple windows utility was very wrong. ok, another attempt to use D for our windows developement has failed. i'm in no way can sell manual ".def" creation to our team -- they will make fun of me, showing how their Visual C can compile this code without any troubles and external utilities... It's easier to run coffimplib on the lib files from the Windows SDK. sorry if i'm rude, i really appreciate your advice. i messed myself thinking that this is another thread in "general" NG. The Windows SDK can be downloaded seperately from visual studio: https://msdn.microsoft.com/en-us/windows/desktop/ff851942.aspx They are also backwards compatible, so the latest one should work on XP. But you can also just use the oldest one available to make sure it still works on your machine.
Re: windows wininet library
On Sun, 01 Feb 2015 16:07:58 +, John Chapman wrote: > On Sunday, 1 February 2015 at 08:37:23 UTC, ketmar wrote: >> >> seems that my idea of using D to write a simple windows utility was >> very wrong. ok, another attempt to use D for our windows developement >> has failed. i'm in no way can sell manual ".def" creation to our team >> -- they will make fun of me, showing how their Visual C can compile >> this code without any troubles and external utilities... > > It's easier to run coffimplib on the lib files from the Windows SDK. sorry if i'm rude, i really appreciate your advice. i messed myself thinking that this is another thread in "general" NG. signature.asc Description: PGP signature
Re: windows wininet library
On Sun, 01 Feb 2015 16:07:58 +, John Chapman wrote: > On Sunday, 1 February 2015 at 08:37:23 UTC, ketmar wrote: >> >> seems that my idea of using D to write a simple windows utility was >> very wrong. ok, another attempt to use D for our windows developement >> has failed. i'm in no way can sell manual ".def" creation to our team >> -- they will make fun of me, showing how their Visual C can compile >> this code without any troubles and external utilities... > > It's easier to run coffimplib on the lib files from the Windows SDK. and what if i don't have that "windows sdk" thing, neither i know about "coffimplib"? actually, i really don't have that sdk, 'cause new visual studio doesn't want to be installed on my xp box, and i gave up searching for old visual studio on ms site (and huh, they are HUGE!). signature.asc Description: PGP signature
Re: windows wininet library
On Sunday, 1 February 2015 at 08:37:23 UTC, ketmar wrote: seems that my idea of using D to write a simple windows utility was very wrong. ok, another attempt to use D for our windows developement has failed. i'm in no way can sell manual ".def" creation to our team -- they will make fun of me, showing how their Visual C can compile this code without any troubles and external utilities... It's easier to run coffimplib on the lib files from the Windows SDK.
Re: Can't understand how to compare DateTime with opCmp
Thanks! Could anybody say how can I use roll if I need to date to date. For example I need to plus: DateTime currentdt = cast(DateTime)(Clock.currTime()); with another DateTime var foo.
Re: Can't understand how to compare DateTime with opCmp
On Sunday, 1 February 2015 at 15:04:39 UTC, Suliman wrote: I need to compare to DateTime. I looked at docs and found opCmp for DateTime type. The problem is that I can't understand how to use it. http://dlang.org/phobos/std_datetime.html#DateTime opCmp(in DateTime rhs); what is rhs? I am trying to do something like this: if( DateTime.opCmp(dtindb, outoftime)); But it's seems that I wrong understand how to use this function... opCmp is the operator overload for the comparison operators, so you can simple write: if(dtindb < outoftime) and it should work.
Re: Can't understand how to compare DateTime with opCmp
On 2015-02-01 at 16:04, Suliman wrote: opCmp(in DateTime rhs); what is rhs? RHS is probably short of "right hand side", ie. the argument on the right side of the operator in a binary operator expression. In `a < b` it would be b. I am trying to do something like this: if( DateTime.opCmp(dtindb, outoftime)); But it's seems that I wrong understand how to use this function... No. That would be `if (dtindb.opCmp(outoftime))`, but it's simpler to write `if (dtindb < outoftime)`
Can't understand how to compare DateTime with opCmp
I need to compare to DateTime. I looked at docs and found opCmp for DateTime type. The problem is that I can't understand how to use it. http://dlang.org/phobos/std_datetime.html#DateTime opCmp(in DateTime rhs); what is rhs? I am trying to do something like this: if( DateTime.opCmp(dtindb, outoftime)); But it's seems that I wrong understand how to use this function...
Re: foreach - premature optimization vs cultivating good habits
Thank you Adam, Bbaz and Ola for the helpful thoughts. I dumped them in a wiki page off the sandbox but needs editing and refining.
Re: Error when profiling
On Saturday, 31 January 2015 at 14:12:59 UTC, Phil wrote: When trying to run my program with profiling enabled it dies before the first line of my main function runs. Everything works fine without profiling. I get the following stack trace: thread #1: tid = 0x38de4, 0x00010008d985 vision_entry`gc_malloc + 49, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0) frame #0: 0x00010008d985 vision_entry`gc_malloc + 49 vision_entry`gc_malloc + 49: -> 0x10008d985: movq (%rdi), %rbx 0x10008d988: callq *0x60(%rbx) 0x10008d98c: popq %rbx 0x10008d98d: movq %rbp, %rsp (lldb) thread backtrace * thread #1: tid = 0x38de4, 0x00010008d985 vision_entry`gc_malloc + 49, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0) * frame #0: 0x00010008d985 vision_entry`gc_malloc + 49 frame #1: 0x0001000908f5 vision_entry`_d_newclass + 117 frame #2: 0x0001000b4b28 vision_entry`D3std9exception7bailOutFNaNfAyamxAaZv + 40 frame #3: 0x0001000b4d06 vision_entry`D3std9exception14__T7enforceTbZ7enforceFNaNfbLAxaAyamZb + 94 frame #4: 0x0001000c4df6 vision_entry`D3std5stdio4File17LockingTextWriter6__ctorMFNcNeKS3std5stdio4FileZS3std5stdio4File17LockingTextWriter + 86 frame #5: 0x0001000c4f19 vision_entry`D3std5stdio4File17lockingTextWriterMFZS3std5stdio4File17LockingTextWriter + 41 frame #6: 0x00012c74 vision_entry`D3std5stdio4File15__T8writeflnTaZ8writeflnMFxAaZv + 124 at stdio.d:1238 frame #7: 0x00010c06 vision_entry`_Dmain + 86 at stdio.d:2727 frame #8: 0x00010009060c vision_entry`D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv + 40 frame #9: 0x000100090551 vision_entry`D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ7tryExecMFMDFZvZv + 45 frame #10: 0x0001000905b1 vision_entry`D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZv + 45 frame #11: 0x000100090551 vision_entry`D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ7tryExecMFMDFZvZv + 45 frame #12: 0x0001000904cd vision_entry`_d_run_main + 433 frame #13: 0x00010d29 vision_entry`main + 65 frame #14: 0x7fff883a45c9 libdyld.dylib`start + 1 Does anyone have any ideas of what could have caused this? What is the source code of your main function? I ask because it looks like it did. frame 13 is C main. frames 12 - 8 are compiler generated. Frame 7 is D main. frame #7: 0x00010c06 vision_entry`_Dmain + 86 at stdio.d:2727 Frame 6 is std.stdio.writefln(...) Frame 5 is the acquisition of the locking text writer frame 4 is the constructor of the locking text writer. THIS IS WHERE THE EXCEPTION IS THROWN. as is evident by frame 3. vision_entry`D3std9exception14__T7enforceTbZ7enforceFNaNfbLAxaAyamZb + 94 where the locking text writer is enforcing some condition. (possibly that it received the correct amour of arguments) Frame 2 is the enforce bailing out Frames 1 is bailout() throwing a _new_ exception. _d_newclass(exception) frame 0 is the gc_malloc attempting to allocate the memory for the exception. and hits a stop reason = EXC_BAD_ACCESS (code=1, address=0x0) -> 0x10008d985: movq (%rdi), %rbx (rbx = *rdi) null pointer somewhere. your main function looks like int main(string[] args) { writefln(...); // Double check whats going on here ... return 0; } try int main(string[] args) { try writefln(...); // Double check whats going on here catch(exception e) { writeln("caught some exception"); // alternatively use printf/puts if written also fails } ... return 0; } and you will see caught some exception instead of the stack trace. Are you profiling with an external profiler or using the compiler to emit profile statistics? My only guess is that there is a bug in the compiler's inserted profiling code. perhaps someone else will be able to help. Nic
Re: dco how to specify Jpath?
On Friday, 9 January 2015 at 16:40:37 UTC, FrankLike wrote: https://github.com/FrankLIKE/dco you can use dco by local.ini( create it by dco -ini ),config your info into local.ini. modify the ';dflag=' to 'dflags=-JyourPath' Thank you.
Re: windows wininet library
On Sun, 01 Feb 2015 07:32:05 +, ketmar wrote: > how can i use wininet.dll from D? i got bindings from > https://github.com/ > CS-svnmirror/dsource-bindings-win32.git, and then i tried to create > wininet.lib with implib.exe from DMC package. no matter how i tried, the > resulting "wininet.lib" seems to not work, as linker keep complaining > about missing symbols like "_InternetReadFile@16" and so on. > > i'm building for win32. > > ah, and yep, i compiled "wininet.lib" to "lib" dir, and added option to > dmd.exe: "-L+wininet.lib". > > i assume that i have to create corrent .def file to remap all the names, > am i right? oh, delightful... so far i solved the problem by using this manually created "wininet.def" file: LIBRARY wininet EXPORTS _InternetReadFile@16=InternetReadFile _InternetCloseHandle@4=InternetCloseHandle _HttpQueryInfoA@20=HttpQueryInfoA _HttpSendRequestA@20=HttpSendRequestA _HttpOpenRequestA@32=HttpOpenRequestA _InternetConnectA@32=InternetConnectA _InternetCrackUrlA@16=InternetCrackUrlA _InternetOpenA@20=InternetOpenA seems that my idea of using D to write a simple windows utility was very wrong. ok, another attempt to use D for our windows developement has failed. i'm in no way can sell manual ".def" creation to our team -- they will make fun of me, showing how their Visual C can compile this code without any troubles and external utilities... signature.asc Description: PGP signature
Re: windows wininet library
On Sun, 01 Feb 2015 08:10:30 +, Jeremy DeHaan wrote: > On Sunday, 1 February 2015 at 07:32:05 UTC, ketmar wrote: >> how can i use wininet.dll from D? i got bindings from >> https://github.com/ >> CS-svnmirror/dsource-bindings-win32.git, and then i tried to create >> wininet.lib with implib.exe from DMC package. no matter how i tried, >> the resulting "wininet.lib" seems to not work, as linker keep >> complaining about missing symbols like "_InternetReadFile@16" and so >> on. >> >> i'm building for win32. >> >> ah, and yep, i compiled "wininet.lib" to "lib" dir, and added option to >> dmd.exe: "-L+wininet.lib". >> >> i assume that i have to create corrent .def file to remap all the >> names, >> am i right? oh, delightful... > > What does your implib command look like? i tried all possible variants -- both "/noi" and "/s", one of them and nothing at all. neither of variants works. the thing is `extern(Windows)` ignores even `pragma(mangle)`, and insisting on names like "_InternetReadFile@16". note the "@16" here -- this is the total size of arguments to `InternetReadFile()`. "wininet.dll" has names without that sizes, so -- no luck. "implib" can't determine the sizes by itself too. so there seems to be no way to create correct library without manually writing ".def" file for it. p.s. i don't know why `extern(Windows)` ignores `pragma(mangle)`. signature.asc Description: PGP signature
Re: windows wininet library
On Sunday, 1 February 2015 at 07:32:05 UTC, ketmar wrote: how can i use wininet.dll from D? i got bindings from https://github.com/ CS-svnmirror/dsource-bindings-win32.git, and then i tried to create wininet.lib with implib.exe from DMC package. no matter how i tried, the resulting "wininet.lib" seems to not work, as linker keep complaining about missing symbols like "_InternetReadFile@16" and so on. i'm building for win32. ah, and yep, i compiled "wininet.lib" to "lib" dir, and added option to dmd.exe: "-L+wininet.lib". i assume that i have to create corrent .def file to remap all the names, am i right? oh, delightful... What does your implib command look like?