Re: How array concatenation works... internally
On Monday, 23 April 2018 at 23:27:17 UTC, Steven Schveighoffer wrote: ... If you want to know more about the array runtime, I suggest this article: https://dlang.org/articles/d-array-article.html ... Thanks for replying and this article is what I was looking for.
Re: How array concatenation works... internally
On Monday, 23 April 2018 at 23:15:13 UTC, Dnewbie wrote: It's related to memcpy? By the way... It's related to realloc and memcpy?
How array concatenation works... internally
Hi, I'd like to understand how array concatenation works internally, like the example below: //DMD64 D Compiler 2.072.2 import std.stdio; void main(){ string[] arr; arr.length = 2; arr[0] = "Hello"; arr[1] = "World"; writeln(arr.length); arr = arr[0..1] ~ "New String" ~ arr[1..2]; writeln(arr.length); foreach(string a; arr){ writeln(a); } } http://rextester.com/DDW84343 The code above prints: 2 3 Hello New String World So, It changes the "arr" length and put the "New String" between the other two. It's very fast with some other tests that I made. Now I'm curious to know what's happening under the hood. It's related to memcpy? On Phobos "array.d" source I've found this: /// Concatenation with rebinding. void opCatAssign(R)(R another) { auto newThis = this ~ another; move(newThis, this); } But now I'm having problem to find how I can reach this "move" function, since I couldn't find any "move" on the "std" folder. Thanks in advance.
Re: Some feedback on the website.
On Tuesday, 15 December 2015 at 07:07:23 UTC, deadalnix wrote: Navigation: The navigation can get very confusing. The forum and the site look the same, but the logo in the top right bring back to the site index/forum index . I thought that only I had saw this. Yes it's wrong. To go to homepage from the forum you need to look at the bottom (D Home link), for me this is very wrong and certainly not the standard for most sites. I really think that D "heads" should hire a webdesigner! Ron.
Re: We need better documentation for functions with ranges and templates
On Tuesday, 15 December 2015 at 09:57:00 UTC, ZombineDev wrote: On Monday, 14 December 2015 at 19:56:29 UTC, dnewbie wrote: On Monday, 14 December 2015 at 19:04:46 UTC, bachmeier wrote: It's unanimous, at least among the three of us posting in this Reddit thread: ... Take for example C# Docs: https://msdn.microsoft.com/en-us/library/system.collections.arraylist.addrange.aspx Syntax C#: public virtual void AddRange( ICollection c ) Parameters: c Type: System.Collections.ICollection The ICollection whose elements should be added to the end of the ArrayList. The collection itself cannot be null, but it can contain elements that are null. Clean, simple and instructive! You are really comparing apples to oranges... If you look here: http://forum.dlang.org/post/xiduyyulihesjgjxm...@forum.dlang.org I said: "but the main focus here was about the simplicity of the layout used in the C# doc. You can see others examples there easily including templates and generics interface." So I was talking about one example vs another, in this case isSameLength, which I suggested something like: Syntax: bool isSameLength(Range1, Range2)(Range1 r1, Range2 r2) Parameters: Type r1, r2 : Input range. Both r1, r2 : needs to be finite. Instead of: bool isSameLength(Range1, Range2)(Range1 r1, Range2 r2) if (isInputRange!Range1 && isInputRange!Range2 && !isInfinite!Range1 && !isInfinite!Range2); But you know I'm newbie... Ron.
Re: We need better documentation for functions with ranges and templates
On Monday, 14 December 2015 at 19:04:46 UTC, bachmeier wrote: It's unanimous, at least among the three of us posting in this Reddit thread: ... Take for example C# Docs: https://msdn.microsoft.com/en-us/library/system.collections.arraylist.addrange.aspx Syntax C#: public virtual void AddRange( ICollection c ) Parameters: c Type: System.Collections.ICollection The ICollection whose elements should be added to the end of the ArrayList. The collection itself cannot be null, but it can contain elements that are null. Clean, simple and instructive! On the otherhand, imagine a newbie looking: bool isSameLength(Range1, Range2)(Range1 r1, Range2 r2) if (isInputRange!Range1 && isInputRange!Range2 && !isInfinite!Range1 && !isInfinite!Range2); Well, most of my friends of college that I indicated D language thinks the D docs is confusing. Ron.
Re: We need better documentation for functions with ranges and templates
On Monday, 14 December 2015 at 20:08:20 UTC, Jack Stouffer wrote: You're not really comparing apples to apples here In fact I'm not, but the main focus here was about the simplicity of the layout used on the C# doc. You can see others examples there easily including templates and generics interface. On the otherhand, imagine a newbie looking: bool isSameLength(Range1, Range2)(Range1 r1, Range2 r2) if (isInputRange!Range1 && isInputRange!Range2 && !isInfinite!Range1 && !isInfinite!Range2); They can look at the examples below and see that the function accepts strings and arrays. And they can look at the parameters section and see that r1 and r2 need to be "finite input range"s if they can't read the function signature. Yes they can and this isn't hard to understand, but remember there are newcomers every day. I think it should be simpler like MSDN does: Syntax: bool isSameLength(Range1, Range2)(Range1 r1, Range2 r2) Parameters: Type r1, r2 : Input range. Both r1, r2 : needs to be finite. I think it's better than currently. But this is my thoughts over the problems that my friends encounter with D's docs. Ron.
Re: Looking for someone that could work on 32 bits support for SDC
On Sunday, 13 September 2015 at 19:49:58 UTC, deadalnix wrote: That's a pitty. libd itself could be usefull to program some tools for the language. I particularly think to IDE stuff like symbol list, module name finder, etc. So far in Coedit I use libdparse but if libd would be available for the 32 bit plateforms I won't be against using it. That's a pitty that everybody ask for it, but nobody makes it happens, expecting it to magically fall from the sky. WTF?
Re: Programming in D paper book is available for purchase
On Wednesday, 19 August 2015 at 00:57:32 UTC, Ali Çehreli wrote: I am very happy! :) Ordered Thank You Ali.
Re: Martin Nowak is officially MIA
I understand the feeling, but that seems unnecessarily harsh to demote Martin, since he is the one that have done the most for release, and it yielded actual results. Indeed.
Re: DMD v2.066.0-rc2
On Friday, 8 August 2014 at 12:01:43 UTC, Andrew Edwards wrote: DMD v2.066.0-rc2 binaries are available for testing: http://wiki.dlang.org/Beta_Testing curl.lib not found in dmd.2.066.0-rc2.windows.zip\dmd2\windows\lib
Re: DMD v2.066.0-rc2
On Monday, 11 August 2014 at 19:32:27 UTC, Brad Anderson wrote: On Monday, 11 August 2014 at 19:02:18 UTC, Brad Anderson wrote: On Monday, 11 August 2014 at 15:51:16 UTC, dnewbie wrote: On Friday, 8 August 2014 at 12:01:43 UTC, Andrew Edwards wrote: DMD v2.066.0-rc2 binaries are available for testing: http://wiki.dlang.org/Beta_Testing curl.lib not found in dmd.2.066.0-rc2.windows.zip\dmd2\windows\lib Should be fixed by https://github.com/D-Programming-Language/installer/pull/108 I accidentally left it out so Andrew had to quickly fix it but he did it shortly after he rolled some of the release. You'll note he regenerated the installer to include it but the zip must have not had a fixed version uploaded. The dmd.2.066-rc2.windows.zip I just downloaded has dmd2/windows/lib/curl.lib OK!
Re: D LDAP library?
On Tuesday, 12 August 2014 at 00:36:17 UTC, Andrei Alexandrescu wrote: Hello, got a question today from a user - is there an LDAP library for D? Thanks! -- Andrei There is a raw binding to openldap c library. http://d.darktech.org/bindings/ldap.zip
Poll - How long have you been in D?
Please vote now! http://www.easypolls.net/poll.html?p=533e10e4e4b0edddf89898c5 See also results from previous years: - http://d.darktech.org/2012.png - http://d.darktech.org/2013.png
Re: sha1Of() crashing and incorrect result on win64
On Thursday, 6 March 2014 at 15:56:07 UTC, Andrej Mitrovic wrote: On 3/6/14, knutaf a...@b.com wrote: and then crashes. If I build without -m64, I get A9993E364706816ABA3E25717850C26C9CD0D89D, which is what I was expecting. It works fine for me using 2.064 and 2.065, both with and without -m64. It doesn't work for me. Incorrect result crash. dmd2.065
Re: sha1Of() crashing and incorrect result on win64
It works with DMD/Phobos from GIT.
Re: Question about function aliases
On Wednesday, 11 December 2013 at 23:42:44 UTC, Gary Willoughby wrote: For example i have some C code like this: typedef void (Tcl_InterpDeleteProc) _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp)); void Tcl_CallWhenDeleted(Tcl_Interp* interp, Tcl_InterpDeleteProc* proc, ClientData clientData); I intend on converted this to D thus: alias void function(ClientData clientData, Tcl_Interp* interp) Tcl_InterpDeleteProc; void Tcl_CallWhenDeleted(Tcl_Interp* interp, Tcl_InterpDeleteProc* proc, ClientData clientData); Is it correct keeping the * with the Tcl_InterpDeleteProc parameter or do i remove it? Is the alias above a function pointer? To call this function can i use a function literal for the Tcl_InterpDeleteProc parameter? or do i need to pass an address of the function? It's a function pointer. Test: import std.stdio; alias extern(C) void function(void*) Callback; void Call(Callback c) { c(c); } extern(C) void callback(void* v) { writefln(v: %04X, v); } void main() { Callback c = callback; Call(c); writefln(c: %04X, c); }
Re: Help needed testing automatic win64 configuration
On Wednesday, 16 October 2013 at 01:15:20 UTC, Brad Anderson wrote: On Tuesday, 15 October 2013 at 06:38:30 UTC, dnewbie wrote: VS 2010 Express/Windows SDK 7.0: dmd -m64 hello.d Can't run 'c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\link.exe', check PATH with dmd-2.064-beta-new-sc.ini-2.exe I believe you need the 7.1 SDK. 7.0 does not come with the 64-bit toolset. I'm not certain about the paths in an Express/7.1 setup. If you can give me the paths to: 1. 64-bit link.exe 2. 64-bit C Runtime libraries (in MSVC this is %VCINSTALLDIR%lib\amd64 but I'm not sure if that comes with Express or with the 7.1 SDK and is located somewhere in SDK's directory structure instead). I might be able to this working. 1. 64-bit link.exe: C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\Bin\amd64\link.exe 2. 64-bit C Runtime libraries: C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\amd64 3. 64-bit Windows import libraries: C:\Program Files\Microsoft SDKs\Windows\v7.0\Lib\x64
Re: Help needed testing automatic win64 configuration
VS 2010 Express/Windows SDK 7.0: dmd -m64 hello.d Can't run 'c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\link.exe', check PATH with dmd-2.064-beta-new-sc.ini-2.exe
Re: Getting the missing Windows functions
On Tuesday, 8 October 2013 at 08:54:44 UTC, Mike Parker wrote: On 10/8/2013 6:57 AM, Andrej Mitrovic wrote: On 10/7/13, Matt webwra...@fastmail.fm wrote: The missing functions (or at least the one I'm interested in at the moment) that I'm trying to use are supposed to be IN kernel32, and have been in there since Windows Vista. That's why I'm a little confused. The kernel32.lib distributed with DMD is likely out of date. See: http://d.puremagic.com/issues/show_bug.cgi?id=6625 It's very out of date. When I need Windows functions that are missing from the DMD libs, I prototype them as function pointers and load them dynamically. It's a one-off investment for each function and I don't need many of them, so no big deal. I always run this when I install a new dmd cd C:\D\dmd2\windows\lib\ coffimplib C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\advapi32.lib advapi32.lib coffimplib C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\comctl32.lib comctl32.lib coffimplib C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\comdlg32.lib comdlg32.lib coffimplib C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\gdi32.libgdi32.lib coffimplib C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\kernel32.lib kernel32.lib coffimplib C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\shell32.lib shell32.lib coffimplib C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\shlwapi.lib shlwapi.lib coffimplib C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\user32.lib user32.lib coffimplib C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\ws2_32.lib ws2_32.lib coffimplib C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\wsock32.lib wsock32.lib
Re: How to cleanup after Socket.bind on Linux?
On Tuesday, 27 August 2013 at 03:30:11 UTC, Ali Çehreli wrote: It cannot be started a second time for 8080 still being in use, unless you wait for several seconds It works on Windows7, no need to wait.
Re: Poll: how long have you been into D
On Saturday, 6 July 2013 at 01:33:09 UTC, dnewbie wrote: Hi. It's time for the annual poll of the year. Please vote http://www.easypolls.net/poll.html?p=51d766e4e4b03d6de547a64b Here are the results. 2012 2013 1 year 27% 21% 1-2 years 25% 27% 3-5 years 28% 31% 6-10 years 19% 21% Total votes 212 201
Re: DLLs: Cleaning up
On Thursday, 11 July 2013 at 12:58:42 UTC, Chris wrote: I have a DLL written in D I load into a Python application via ctypes like so: lib = CDLL(mydll) The DLL loads and can be used no problem. However, once the DLL is discarded of by the program, the program either doesn't react or crashes. I still haven't worked out how to clean up the DLL correctly before it is unloaded / detached (from Python). I guess it's the GC and/or some C stuff I've overlooked. I have tried both approaches described on this page: http://dlang.org/dll.html. Maybe someone of yous once had a similar problem and found a solution. Any hints or suggestions would be appreciated. Thanks. Ye. Please try compiling your DLL with GDC.
Re: Linear algebra for Win64?
On Tuesday, 9 July 2013 at 19:02:09 UTC, Kevin McTaggart wrote: Does anyone know of a good D linear algebra library for Win64? I tried scid a year ago and liked it on Win32, but have been unable to get it to link on Win64. When trying to run scid on Win64, I've been using prebuilt LAPACK 3.4.1 libraries from http://icl.cs.utk.edu/lapack-for-windows/lapack/, but have unresolved external symbol dgesv_ You can try this: /* 1. Create ABC.DEF with MS-NOTEPAD cut --- LIBRARY LIBLAPACK.DLL EXPORTS dgesv_ cut --- 2. Create ABC.LIB with MS-LIB C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\Bin\amd64\lib.EXE /DEF:ABC.DEF /MACHINE:X64 /OUT:ABC.LIB 3. Compile link dmd -m64 test1.d ABC.lib 4. Run test1.exe The solution is -0.661082 9.456125 -16.014625 */ import std.stdio; extern(System) void dgesv_(const(int)* N, const(int)* nrhs, double* A, const(int)* lda, int* ipiv, double* b, const(int)* ldb, int* info); void main() { /* 3x3 matrix A * 76 25 11 * 27 89 51 * 18 60 32 */ double A[9] = [76, 27, 18, 25, 89, 60, 11, 51, 32]; double b[3] = [10, 7, 43]; int N = 3; int nrhs = 1; int lda = 3; int ipiv[3]; int ldb = 3; int info; dgesv_(N, nrhs, A.ptr, lda, ipiv.ptr, b.ptr, ldb, info); if (info == 0) /* succeed */ writefln(The solution is %f %f %f, b[0], b[1], b[2]); else writefln(dgesv_ fails %d, info); }
Poll: how long have you been into D
Hi. It's time for the annual poll of the year. Please vote http://www.easypolls.net/poll.html?p=51d766e4e4b03d6de547a64b
Re: DConf 2013 Day 1 Talk 2: Copy and Move Semantics in D by Ali Cehreli
On Friday, 10 May 2013 at 12:08:10 UTC, Andrei Alexandrescu wrote: Enjoy! https://www.youtube.com/watch?v=mPr2UspS0fE Andrei Very good presentation. Thank you Ali.
Re: x64 Link Issues - Can someone please help?
phobos64.lib(dmain2_4ac_1a5.obj) : error LNK2019: unresolved external symbol _Dmain referenced in function main Please add -L/DLL to the command line.
Re: D 2.062 release
On Monday, 18 February 2013 at 01:02:43 UTC, Walter Bright wrote: http://digitalmars.com/d/download.html The dlang.org site isn't updated yet, but the downloads are there. Thank you Walter Bright. I appreciate your work.
Trouble with DLL address
I have a DLL which exports a function GetFunction. GetFunction returns a pointer to RealFunction. Now I want to run RealFunction from my D program, but for some reason I get the wrong address. Here is the code. dll64.c - #define WIN32_LEAN_AND_MEAN #include windows.h int __stdcall RealFunction(int a) { return a + 1; } typedef int (__stdcall *FuncPtr)(int); FuncPtr __stdcall GetFunction() { return RealFunction; } mydll64.def LIBRARY mydll64.dll EXPORTS GetFunction - build with MSVC64: cl -c dll64.c -Fomydll64.obj link /DLL /OUT:mydll64.dll mydll64.obj /DEF:mydll64.def And this is the D program. testdll64d.d // dmd -m64 -c testdll64d.d -oftestdll64d.obj // link /OUT:testdll64d.exe testdll64d.obj import core.runtime; import std.c.windows.windows; import std.stdio; alias extern(Windows) int function(int) FuncPtr; int main(string[] args) { HMODULE dll = LoadLibraryA(mydll64.DLL); FARPROC getFunction = GetProcAddress(dll, GetFunction); FuncPtr realFunction = cast(FuncPtr) getFunction(); writefln(dll address: %08x, dll); writefln(GetFunction address: %08x, getFunction); writefln(RealFunction address: %08x, realFunction); writefln(RealFunction result: %d, realFunction(7));//-- CRASH return 0; } -- Output: dll address: 18000 GetFunction address: 180001020 RealFunction address: 80001000 CRASH BTW, this works: FuncPtr realFunction = cast(FuncPtr) (getFunction() 0x | cast(size_t) dll);
Re: Trouble with DLL address
The problem is FARPROC. Thank you everybody. Solution: import core.runtime; import std.c.windows.windows; import std.stdio; alias extern(Windows) int function(int) FuncPtr; alias extern(Windows) FuncPtr function() GetFuncPtr; int main(string[] args) { HMODULE dll= LoadLibraryA(mydll64.DLL); GetFuncPtr getFunction = cast(GetFuncPtr) GetProcAddress(dll, GetFunction); FuncPtr realFunction = cast(FuncPtr) getFunction(); writefln(dll address: %08x, dll); writefln(GetFunction address: %08x, getFunction); writefln(RealFunction address: %08x, realFunction); writefln(RealFunction result: %d, realFunction(7)); return 0; }
Re: Creation of import libraries for Windows
On Thursday, 10 January 2013 at 17:29:13 UTC, Phil Lavoie wrote: Hi all, This is actually a duplicate of my post on the D.learn forums :). I am concerned that it hasn't been answered only because it is in a less popular sub forum. I'll try to make it short. This websites recommends implib for the creation of import library therefore I have been using it. When I compile + link my code containing extern( Windows ) function declarations, I get the following messages: Error 42: Symbol Undefined _functionName@ordinal (generic case) Error 42: Symbol Undefined _glGetIntegerv@8 (just an example) Let's hypothesize that I am using shared.dll and I would like to statically link against it using an import library. I use this command: implib /noi /system shared.lib ..\shared.dll To generate the import library. Once done, I make sure the linker finds it and rebuild the program. I get the same errors. Hello Phil Lavoie. Yes, sometimes implib works and sometimes it doesn't. Please check http://blogs.msdn.com/b/oldnewthing/archive/2006/07/27/679634.aspx The fact that names in import libraries are decorated means that it is doubly crucial that you use the official import library for the DLL you wish to use rather than trying to manufacture one with an import library generation tool. As we noted earlier, the tool won't know whether the ordinal assigned to a named function was by design or merely coincidental. But what's more, the tool won't know what decorations to apply to the function (if the name was exported under an undecorated name). Consequently, your attempts to call the function will fail to link since the decorations will most likely not match up. Therefore, I looked into the import library only to find that no exported symbols have and ordinal appended (@someInt), CONTRARILY to the symbols you can find in the import library provided by the compiler (..\D\windows\lib\*). ..@someInt is actually called a 'decoration'. So... how were those generated in the first place (what makes them have those ordinals, was this an automated process or did someone actually wrote the module definition files by hand)? I can't give you an exact answer (I'm not from Digital Mars :)), but I believe they used http://www.digitalmars.com/ctg/coffimplib.html against the official .libs from the Windows SDK. Writing .def by hand is also an option. How and why is extern( Windows ) generating symbol calls expecting ordinals for stdcall conventions (how does it know that _glGetIntegerv has an ordinal of 8 for example)? Is the ordinal a desirable requirement for those calls? From http://msdn.microsoft.com/en-us/library/zxk0tw93(v=vs.71).aspx An underscore (_) is prefixed to the name. The name is followed by the at sign (@) followed by the number of bytes (in decimal) in the argument list. Therefore, the function declared as int func( int a, double b ) is decorated as follows: _func@12 Conclusion If you have the shared.dll only, try 'implib' or 'implib /system'. This may not work if the .dll contains stdcall functions exported as 'undecorated'. If you have the official shared.lib, try coffimplib. If you have both shared.dll and shared.h, you can write a module definition file by hand.
Re: What's up with the windows headers?
On Wednesday, 26 December 2012 at 21:56:31 UTC, Phil Lavoie wrote: All right I got a problem now. Including winver.d triggers the inclusion of version.lib through this: pragma(lib, version.lib); However, this import library does not exist. So I created it using,implib /noi /system version.lib ...\System32\version.dll then moved it to the dmd\windows\lib folder. Now when running using rdmd I get this error message: --- errorlevel 1 Which means... WHAT?!?!?!?! Thanks for any help If you have the Windows SDK: cd C:\D\dmd2\windows\lib\ coffimplib C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\version.lib version.lib
Re: D Stable Proposal
Wait.. what happened to dlang-stable? http://forum.dlang.org/thread/op.whi33qsp707...@invictus.skynet.com
Re: #define trouble
On Tuesday, 27 November 2012 at 06:27:49 UTC, Ali Çehreli wrote: On 11/26/2012 10:05 PM, dnewbie wrote: I have the following C struct from ldap.h typedef struct ldapmod { int mod_op; char *mod_type; union mod_vals_u { char **modv_strvals; struct berval **modv_bvals; } mod_vals; #define mod_values mod_vals.modv_strvals #define mod_bvalues mod_vals.modv_bvals } LDAPMod; It is used like this: LDAPMod title; title.mod_values = x; I wonder how can I write the line 'title.mod_values = x;' in D. Currently I do like this: struct ldapmod { int mod_op; char* mod_type; union mod_vals_u { char** modv_strvals; berval** modv_bvals; } mod_vals_u mod_vals; } alias ldapmod LDAPMod; LDAPMod title; title.mod_vals.modv_strvals = x; A pair of @property functions would work, one of which may be unnecessary: alias int berval; struct ldapmod { intmod_op; char* mod_type; union mod_vals_u { char** modv_strvals; berval** modv_bvals; } mod_vals_u mod_vals; char** mod_values() @property { return mod_vals.modv_strvals; } void mod_values(char** value) @property { mod_vals.modv_strvals = value; } // similarly for mod_bvalues... } alias ldapmod LDAPMod; void main() { LDAPMod title; char** x; // title.mod_vals.modv_strvals = x; title.mod_values = x; } Ali Perfect! Thank you.
#define trouble
I have the following C struct from ldap.h typedef struct ldapmod { int mod_op; char *mod_type; union mod_vals_u { char **modv_strvals; struct berval **modv_bvals; } mod_vals; #define mod_values mod_vals.modv_strvals #define mod_bvalues mod_vals.modv_bvals } LDAPMod; It is used like this: LDAPMod title; title.mod_values = x; I wonder how can I write the line 'title.mod_values = x;' in D. Currently I do like this: struct ldapmod { int mod_op; char* mod_type; union mod_vals_u { char** modv_strvals; berval** modv_bvals; } mod_vals_u mod_vals; } alias ldapmod LDAPMod; LDAPMod title; title.mod_vals.modv_strvals = x;
Re: Windows DLLs and TLS
You can try compiling it with GDC! Please check this thread: http://forum.dlang.org/thread/nowjthaqnjfrcvqeu...@forum.dlang.org
Re: std.demangle.demangle does not parse symbols that are type names
Why don't you remove the 'create thread' button from this forum? Lazy people...
Re: dmd 1.075 and 2.060 release
Memory usage of my program when compiled by dmd2.057, 2.058, 2.059 2.060: http://postimage.org/image/hqn6l4l8p/ It's a great improvement. Thanks for the new release.
Re: Wiki page for C bindings / wrappers and reimplementations
On Wednesday, 1 August 2012 at 17:18:36 UTC, Marco Leise wrote: Am Mon, 30 Jul 2012 16:50:57 +0200 schrieb Marco Leise marco.le...@gmx.de: I have now written a simple web site the lists C bindings by category. It is updated every day. http://mleise.abcz8.com/d/bindings.php Currently it only lists Deimos repositories and includes them even if they only contain C headers. Oh and it is ugly. libnotify description is truncated.
Re: D support in Exuberant Ctags 5.8 for Windows
On Thursday, 26 July 2012 at 22:06:08 UTC, Gary Willoughby wrote: I'm looking at this page and trying to download the latest CTags 5.8 with D patch compiled for Windows but i'm getting a dead link. Does anyone else have this file or can point me to another link? http://prowiki.org/wiki4d/wiki.cgi?ReferenceForTools/ExuberantCtags There is --ctags output in Dscanner https://github.com/Hackerpilot/Dscanner
Re: phobos breakage... why?
On Wednesday, 25 July 2012 at 17:24:06 UTC, Adam D. Ruppe wrote: I was just playing with the beta, and got this among the sea of errors: arsd/cgi.d(898): Error: function std.algorithm.indexOf!(a == b,ubyte[],string).indexOf is deprecated Why was that taken out? If you ask me, the root cause of D's perceived stability problem has little to do with bugs. It is 95% phobos devs removing functionality at random. Why do we keep doing this? One of my programs stopped working in 2.060. It is *really* annoying when I see the message 'X is deprecated'.
Re: Optional name mangling
On Monday, 23 July 2012 at 20:57:37 UTC, Stuart wrote: On Monday, 23 July 2012 at 17:28:38 UTC, David Nadlinger wrote: On Monday, 23 July 2012 at 17:25:43 UTC, Stuart wrote: Fair enough. But there are still times when we need a version of export that doesn't mangle. No. This is even impossible to do with some compiler backends. For example, LLVM on OS X automatically appends an underscore to the beginning of symbol names, because every C function has an »extra« underscore at the beginning there. I mean for importing. The functions in shlwapi.lib don't have underscores. We ought to have some kind of syntax for importing them without faffing about with .def files. Surely it must be possible? Hi Stuart. If you have the Windows SDK you can run coffimplib C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\shlwapi.lib C:\D\dmd2\windows\lib\shlwapi.lib We could run coffimplib on *.lib from the Windows SDK and include the resulting OMF libraries on the dmd.zip package. I don't know if it is 'legal'.
Re: WinAPI LowLevel Keyboard Hooks
On Thursday, 19 July 2012 at 15:49:48 UTC, DLimited wrote: But what are the differences of loading the Unicode version vs. the ANSI version? I called the Unicode one because I figured that would be the sensible choice, since Unicode is the default for D (if I remember correctly). I have no clue what the actual effects of calling the wrong version would be. Anyway, here's the of my .dll: -- Code begin -- import std.c.windows.windows; import core.sys.windows.dll; import core.runtime; extern (C) void gc_init(); extern (C) void gc_term(); extern (C) void _minit(); extern (C) void _moduleCtor(); extern (C) void _moduleDtor(); extern (Windows) struct KBDLLHOOKSTRUCT { DWORD vkCode; DWORD scanCode; DWORD flags; DWORD time; ULONG_PTR dwExtraInfo; }; extern (Windows) LRESULT CallNextHookEx( int function() hhk, int nCode, WPARAM wParam, LPARAM lParam ); __gshared HINSTANCE g_hInst; extern (Windows) BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved) { return true; switch (ulReason) { case DLL_PROCESS_ATTACH: g_hInst = hInstance; Runtime.initialize; //dll_process_attach( hInstance, true ); break; case DLL_PROCESS_DETACH: dll_process_detach( hInstance, true ); break; case DLL_THREAD_ATTACH: dll_thread_attach( true, true ); break; case DLL_THREAD_DETACH: dll_thread_detach( true, true ); break; default: return true; } return true; } extern (Windows) LRESULT LowLevelKeyboardProc(int code, WPARAM wParam, LPARAM lParam) { KBDLLHOOKSTRUCT* details = cast(KBDLLHOOKSTRUCT*) lParam; MessageBoxA(null, cast(char *)WHOA, Error, MB_OK | MB_ICONEXCLAMATION); if(code == 0 wParam == WM_KEYDOWN) { if(details.vkCode == 0x41) { return 1; } } return CallNextHookEx(null, code, wParam, lParam); } -- Code End -- Lots of copypaste was used. I injected some senseless code to try and check if a specific function ever gets called, though I now realise the DllLoad itself is what fails. Haven't cleaned it back up yet, though. The .def file contains the following: (including newlines) -- .DEF BEGIN -- LIBRARY keydll.dll EXETYPE NT SUBSYSTEM WINDOWS CODE PRELOAD DATA PRELOAD -- .DEF END -- I compiled the dll using: dmd -ofkeydll.dll -L/IMPLIB keydll.d keydll.def No linker/compiler errors. I guess you have to 'export' the function: extern (Windows) export LRESULT LowLevelKeyboardProc(int code, WPARAM wParam, LPARAM lParam) and include EXPORTS LowLevelKeyboardProc in the .DEF file
Re: WinAPI LowLevel Keyboard Hooks
You don't see the WHOA message? Try this alias HANDLE HHOOK;
Re: WinAPI LowLevel Keyboard Hooks
On Thursday, 19 July 2012 at 17:48:06 UTC, DLimited wrote: On Thursday, 19 July 2012 at 17:35:29 UTC, dnewbie wrote: You don't see the WHOA message? Try this alias HANDLE HHOOK; No, I don't get any message after key-presses. I changed int function() to HANDLE, sadly it still doesn't work. For some reason, it doesn't work with 'Thread.sleep' This works: http://dpaste.dzfl.pl/1e6e5960
Re: WinAPI LowLevel Keyboard Hooks
On Thursday, 19 July 2012 at 18:56:15 UTC, DLimited wrote: On Thursday, 19 July 2012 at 18:40:15 UTC, dnewbie wrote: On Thursday, 19 July 2012 at 17:48:06 UTC, DLimited wrote: On Thursday, 19 July 2012 at 17:35:29 UTC, dnewbie wrote: You don't see the WHOA message? Try this alias HANDLE HHOOK; No, I don't get any message after key-presses. I changed int function() to HANDLE, sadly it still doesn't work. For some reason, it doesn't work with 'Thread.sleep' This works: http://dpaste.dzfl.pl/1e6e5960 It doesn't work for me. I can 1 Message Box from the Code in MyWinMain, but none for the Keystrokes. I registered a hook for Keyboard input, and that code is supposed to produce a message box aswell. The function for that is called LowLevelKeyboardProc and located in above-mentioned .dll file. The registering of the hook seems to pass, but the function never actually gets called. Did you add EXPORTS LowLevelKeyboardProc to the .DEF file? It works here.
Re: WinAPI LowLevel Keyboard Hooks
On Thursday, 19 July 2012 at 19:51:31 UTC, DLimited wrote: Yes, I did. Are the newlines important? And you really get a MessageBox per keystroke? I start as admin, disabled my AV but still, no success. Yes, I get 2 WHOA messages. One from the WM-KEYDOWN and the other from WM-KEYUP. Sorry I don't know what is wrong.
Re: Some guidance on writing a Deimos C library interface
Hi Jens. 1. The D page says they should be lower case. Should Deimos module names also be made lower case? Yes. 2. Should all interfaces be put in a common package, say deimos? Yes. * const T* should be replaced with const(T)* Yes. * How to deal with macros? http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.comgroup=digitalmars.Dartnum=146873 Also please check this guide http://www.gamedev.net/blog/1140/entry-2254003-binding-d-to-c/
Re: Winamp plugin
On Friday, 6 July 2012 at 00:38:28 UTC, dnewbie wrote: It works without error when compiled by GDC. Thanks. Here it is http://my.opera.com/run3/blog/2012/07/12/copyto-winamp-plugin It adds an item in Winamp 'Send to' menu
Re: Linking OpenSSL on Windows
On Sunday, 8 July 2012 at 22:33:15 UTC, Andy wrote: I've been using D on linux for a few months now and have the hang of it. I wrote a project that should be able to be compiled on both Linux and Windows. I've gotten it to work excellently on Linux, but I can't seem to figure out how to link the openssl dll files on Windows. On linux, a simple passing of -lssl and -lcrypto the ld works great, but what do I need to do for this to work with optlink? I think you need to generate an import library from the openssl dll file, then use the generated .lib file in optlink command line, see http://www.digitalmars.com/ctg/implib.html
Re: Winamp plugin
On Thursday, 5 July 2012 at 08:55:33 UTC, Denis Shelomovskij wrote: What's your OS? If Windows XP, than D DLL can't be unloaded because of non-perfect TLS fixing technique (I created a perfect one but I never managed to prepare such projects for release so nobody knows about them). And on any Windows Digital Mars C runtime behaves very nasty when it's dynamically loaded. IIRC, it do bad things when loaded in non-main with TLS index != 0 thread and when unloaded (IIRC, again, at least it closes handles). Hi. OS is Windows7-64bit. When I run Winamp in windbg, windbg crashes. The last information I can see is 'Module Unload: C:\WINDOWS\WINSXS\X86_\MSVCR90.DLL' Thanks.
Re: Winamp plugin
It works without error when compiled by GDC. Thanks.
Winamp plugin
I'm writing a Winamp plugin in D. Winamp loads my plugin and everything is fine until I close Winamp. At this point, Winamp calls the Quit() function of my plugin and *after* that, Winamp crashes. Here is the code. D source http://dpaste.dzfl.pl/e2b2f886 myplugin.def - .DEF file --- LIBRARY ml_myplugind.dll EXETYPE NT SUBSYSTEM WINDOWS EXPORTS winampGetMediaLibraryPlugin --- Compile: dmd myplugin.d myplugin.def -ofml_myplugind.dll -L/IMPLIB Copy ml_myplugind.dll to 'C:\Program Files (x86)\Winamp\Plugins' Restart Winamp and go to Options - Preferences - Plugins - Media Library. You'll see 'My Cool Plugin D' [ml_myplugind.dll]' that means the plugin was loaded. Close Winamp. You'll see a message box 'Quit() from D', from the plugin and MS-Windows displays a error dialog. Click more information and it says APPCRASH module ml_myplugind.dll. I have tried the following C code which does the same thing, and I've got no APPCRASHES http://pastebin.com/7t8jkfn8 I can't see what is wrong. Any help is appreciated. More information about Winamp plugin: http://wiki.winamp.com/wiki/Media_Library_Plugin
Re: Build WindowsApi bindings with dmd?
On Monday, 2 July 2012 at 22:10:00 UTC, Damian wrote: I was looking through the bindings and only see a makefile for GNU make. Is there a version for dmd? I really wanted to avoid GNU make if possible. You can try this https://github.com/AndrejMitrovic/WindowsAPI/downloads
Re: d language Bye
On Monday, 2 July 2012 at 01:18:29 UTC, 拖狗散步 wrote: On Monday, 2 July 2012 at 01:08:30 UTC, Alex Rønne Petersen wrote: On 02-07-2012 03:04, 拖狗散步 wrote: d language Bye! Although you are very beautiful, but not for wife! wat hoho! dlang is very beautiful, but not is my wife! lol, you're crazy man. bye
Re: function pointer when a function is overloaded.
import std.stdio; alias void function(int) fooInt; alias void function(long) fooLong; int main(string[] args) { fooInt f1 = foo; fooLong f2 = foo; f1(1L); f2(1L); return 0; } void foo(int i) { writeln(foo(int i)); } void foo(long i) { writeln(foo(long i)); }
Re: dpj for Windows
The dpj mini-ide now displays the name of the current function (from caret position): http://postimage.org/image/exbtxftqv/ Click on the combobox item to jump to the selected function. Thanks dscanner by Sir Alaran https://github.com/Hackerpilot/Dscanner Link: https://github.com/dnewbie/dpj
Re: dpj for Windows
On Tuesday, 22 May 2012 at 07:28:04 UTC, Ary Manzana wrote: On 5/22/12 8:55 AM, dnewbie wrote: On Monday, 21 May 2012 at 12:08:33 UTC, Ary Manzana wrote: On 5/20/12 10:37 PM, dnewbie wrote: It started as a D project, then I've moved it to C. o_O Why? Because the d version of the program has a lot of weird bugs and I wasn't able to kill them. Then why did you still write a D IDE if you couldn't even write it in D? Did you report the bugs? Are they known? Did you try to fix them or to ask the community? Hi. The dpj mini-ide is now written in D and the source code is available: https://github.com/dnewbie/dpj Sorry, there's no new feature. Screenshot: http://postimage.org/image/6mtk293s7/
OPENFILENAME structure
There's information missing in OPENFILENAME structure file core.sys.windows.windows.d http://msdn.microsoft.com/en-us/library/windows/desktop/ms646839%28v=vs.85%29.aspx #if (_WIN32_WINNT = 0x0500) void *pvReserved; DWORD dwReserved; DWORD FlagsEx; #endif
Re: Windows - ZeroMemory macro
On Sunday, 27 May 2012 at 03:55:58 UTC, jerro wrote: On Sunday, 27 May 2012 at 03:29:17 UTC, dnewbie wrote: In C I can write OPENFILENAME ofn; ZeroMemory(ofn, sizeof(ofn)); In D, there is no ZeroMemory. Please help me. You could use c memset: import std.c.string; memset(cast(void*)ofn, 0, ofn.sizeof); or this: (cast(byte*) a)[0 .. a.sizeof] = 0; Thank you.
Re: dpj for Windows
On Tuesday, 22 May 2012 at 07:28:04 UTC, Ary Manzana wrote: On 5/22/12 8:55 AM, dnewbie wrote: On Monday, 21 May 2012 at 12:08:33 UTC, Ary Manzana wrote: On 5/20/12 10:37 PM, dnewbie wrote: It started as a D project, then I've moved it to C. o_O Why? Because the d version of the program has a lot of weird bugs and I wasn't able to kill them. Then why did you still write a D IDE if you couldn't even write it in D? Did you report the bugs? Are they known? Did you try to fix them or to ask the community? Yeah. The development in D should be resumed. For now, there's a minor update available: http://my.opera.com/run3/blog/2012/05/20/dpj The program now uses dscanner https://github.com/Hackerpilot/Dscanner for tag finding.
Windows - ZeroMemory macro
In C I can write OPENFILENAME ofn; ZeroMemory(ofn, sizeof(ofn)); In D, there is no ZeroMemory. Please help me.
Re: dpj for Windows
On Monday, 21 May 2012 at 12:08:33 UTC, Ary Manzana wrote: On 5/20/12 10:37 PM, dnewbie wrote: It started as a D project, then I've moved it to C. o_O Why? Because the d version of the program has a lot of weird bugs and I wasn't able to kill them.
Re: dpj for Windows
On Sunday, 20 May 2012 at 03:53:43 UTC, Nick Sabalausky wrote: dnewbie r...@myopera.com wrote in message news:qufvdhexcdzabuzqr...@forum.dlang.org... dpj is a mini-ide for the D programming language. http://my.opera.com/run3/blog/2012/05/20/dpj That's a good start! Not bad. Is it written in D? It started as a D project, then I've moved it to C. A few notes: - It's much faster to just pass all the files to dmd at once and compile/link all in one step. So, instead of this: dmd -wi -c a.d -ofoutput\a.d dmd -wi -c b.d -ofoutput\b.d dmd -ofa.exe output\a.obj output\b.obj Just do this: dmd -wi -ofa.exe -odoutput a.d b.d It's a lot faster, plus in my experience compiling separately can sometimes lead to linking problems (somehting to do with how dmd handles templates, I think). Understood. - To support things like ldc, gdc and dvm (via ldmd, gdmd, dvm-current-dc.bat, etc...), the config file should take a path to the actual exe or bat (such as dmd.exe) the users wants to run, instead of just the path to dmd.exe. So like dmd_path=C:\D\dmd2\windows\bin\dmd.exe insetad of dmd_path=C:\D\dmd2\windows\bin The project file is actually a GNU makefile with special variables. I'll see how can I make a makefile that supports multiple compilers and compile/link in one step. - The first couple times I made a new project I got some error about it not being able to copy a template. But then it seemed to work ok anyway. I don't remember exactly what it said, and it doesn't seem to be happening anymore (don't know why) so I can't check. It happens when either the destination file already exists, or when the template file is missing. I'll add a more descriptive message. - It *seems* to start up with a default blank project, but you can't use it. You still have to go to File-New project. That's a little confusing. - It'd be good to be able to select and copy the text in the compilation panel at the bottom. - It'd be intuitive to be able to add files to a project by right-clicking D source files or whatever and then have Add file(s)... in a drop-down menu. - More features and configurability with both building and interface would be nice to have in later versions, ie more bells and whistles ;) Right. I'll improve it as time permits. I love that the interface is super-fast, light on memory, and uses the native system controls. And the automatic build management and Help links are really nice to have. Thanks for the feedback!
Re: libraries and c++ compatibility
On Sunday, 13 May 2012 at 02:44:22 UTC, Jason King wrote: I'm trying to use ocilib (deimos\ocilib) bindings and having some issues. dmd 2.0.59, Windows 7 64 bit. I can change sc.ini to get everything to build. I can compile with dmd myapp.d -Ipath_to_deimos -c, but I can't seem to figure out the right switches to make the app find the ociliba-dm.lib that I generated. Using sc.ini seems to work, using the lib environment variable seems to work but I'd like to understand how to make the command line switches work. The compiled application hangs the first time it calls an ocilib routine and I don't expect you folks to debug that for me but it occurred to me that since I have the paid-for version of dmc I could try essentially the same code vs. c++ and if it worked that would isolate the problem to the ocilib.d header. I have the same can't find the library with command line switches problem but I suspect the D fix will help me c++-wise as well. The unique to c++ issue is shows like so. C:\ocilib\ocilib3.9.3\lib32dmc myapp.cpp -c -Ic:\ocilib\ocilib3.9.3\include C:\ocilib\ocilib3.9.3\lib32optlink myapp.obj,,,ociliba-dm.lib OPTLINK (R) for Win32 Release 7.50B1 Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved myapp.obj(myapp) Error 42: Symbol Undefined _OCI_Cleanup myapp.obj(myapp) Error 42: Symbol Undefined _OCI_GetString ... 7 more, covering all ocilib calls. running lib -l vs. ociliba-dm.lib shows symbols with @ signs appended, e.g. _OCI_Cleanup@0 and _OCI_GetString@8. I suspect there's some simple disconnect on my part here, but I can't see it. Any assistance deeply appreciated. Please try adding `-DOCI_API=__stdcall -DOCI_CHARSET_ANSI` to dmc command line. (check http://orclib.sourceforge.net/doc/html/group__g__install.html) If you get runtime errors, please check your ORACLE_HOME environment variable and make sure your %ORACLE_HOME%\bin directory is in your PATH environment variable.
Re: libraries and c++ compatibility
On Sunday, 13 May 2012 at 19:01:15 UTC, Jason King wrote: . C:\ocilib\ocilib3.9.3\lib32dmc myapp.cpp -c -Ic:\ocilib\ocilib3.9.3\include C:\ocilib\ocilib3.9.3\lib32optlink myapp.obj,,,ociliba-dm.lib OPTLINK (R) for Win32 Release 7.50B1 Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved myapp.obj(myapp) Error 42: Symbol Undefined _OCI_Cleanup myapp.obj(myapp) Error 42: Symbol Undefined _OCI_GetString ... 7 more, covering all ocilib calls. Please try adding `-DOCI_API=__stdcall -DOCI_CHARSET_ANSI` to dmc command line. (check http://orclib.sourceforge.net/doc/html/group__g__install.html) If you get runtime errors, please check your ORACLE_HOME environment variable and make sure your %ORACLE_HOME%\bin directory is in your PATH environment variable. Thanks for the help. All I did was generate a OMF library running IMPLIB vs. OCILIBA.DLL. I think your suggestion involves building OCILIB from scratch. Is that right? No. You should add '-DOCI_API=__stdcall -DOCI_CHARSET_ANSI' to dmc when building your c/cpp app. Rebuilding the library looks like a job and I want to make sure that's what I need to do to proceed.
Re: mysql binding/wrapper?
On Saturday, 28 April 2012 at 15:30:13 UTC, simendsjo wrote: stuff/blob/master/mysql.d http://my.opera.com/run3/blog/2012/03/13/d-mysql I use it in a bank account application. It works.
Re: Let's give a honor to dead giants!
On Sunday, 22 April 2012 at 00:58:58 UTC, Brian Schott wrote: On Friday, 20 April 2012 at 03:33:43 UTC, H. S. Teoh wrote: One thing I miss, though, is ctags support for D. 1. It seems that everything can understand Ctags 2. The format's not complicated at all. I just committed support for a --ctags option to my brain-dead D tool (https://github.com/Hackerpilot/Dscanner). Don't expect magic from it, but it should at least be functional. Hello Brian Schott. Thanks for creating this tool. Do you plan on adding support to win32 sources? ex. https://github.com/AndrejMitrovic/DWinProgramming/tree/master/Samples it seems dscanner doesn't like 'extern (Windows)' functions.
Re: string concatenation
On Sunday, 8 April 2012 at 05:27:50 UTC, Jonathan M Davis wrote: On Sunday, April 08, 2012 07:08:09 dnewbie wrote: I have a wchar[] and I want to convert it to UTF8 then append a string. This is my code. import std.c.windows.windows; import std.string; import std.utf; int main() { wchar[100] v; v[0] = 'H'; v[1] = 'e'; v[2] = 'l'; v[3] = 'l'; v[4] = 'o'; v[5] = 0; string s = toUTF8(v) ~ , world!; MessageBoxA(null, s.toStringz, myapp, MB_OK); return 0; } I want Hello, world!, but the result is Hello only. Please help me. D strings are not null-terminated, so v[5] = 0 doesn't do anything to terminate that string. The whole point of toStringz is to put a null character on the end of a string (and allocate a new string if need be) and return a pointer to it. C code will then use the null character to indicate the end of the string, but D won't. What you've done with string s = toUTF8(v) ~ , world!; is create a string that is ['H', 'e', 'l', 'l', 'o', '\0', '\0', '\0', ...] (all of the characters up to the v[99] are '\0') and append [',', ' ', 'w', 'o', 'r', 'l', 'd', '!'] to it. The result is a string whith is 108 characters long with a ton of null characters in the middle of it. When you call toStringz on it, it may or may not allocate a new string, but in the end, you have a string which is 109 characters long with the last character being '\0' (still with all of the null characters in the middle) which you get an immutable char* pointing to. So, when the C code operates on it, it naturally stops processing when it hits the first null character, since that's how C determines the end of a string. You can embed null characters in a string and expect C to operate on the whole thing. And since D strings aren't null-terminated, you can't expect that setting any of it their elements to null will do anything to terminate the string in D or stop D functions from operating on the whole string. You have to slice the static wchar array with the exact elements that you want if you intend to terminate it before its end. - Jonathan M Davis OK. Thank you.
string concatenation
I have a wchar[] and I want to convert it to UTF8 then append a string. This is my code. import std.c.windows.windows; import std.string; import std.utf; int main() { wchar[100] v; v[0] = 'H'; v[1] = 'e'; v[2] = 'l'; v[3] = 'l'; v[4] = 'o'; v[5] = 0; string s = toUTF8(v) ~ , world!; MessageBoxA(null, s.toStringz, myapp, MB_OK); return 0; } I want Hello, world!, but the result is Hello only. Please help me.
Re: Oracle Database - ocilib
On Thursday, 5 April 2012 at 06:15:59 UTC, Walter Bright wrote: On 4/4/2012 9:47 AM, dnewbie wrote: On Tuesday, 3 April 2012 at 04:01:07 UTC, dnewbie wrote: It also works on Linux (I've just tested it on Debian Squeeze with Oracle Express) Rock'n'roll! Hi. I'd like to submit these bindings to be reviewed for inclusion in Deimos. Sure. For that I need a url of original C library, and a brief description. Description (from sourceforge.net project page) OCILIB is an open source and cross platform Oracle Driver that delivers efficient access to Oracle databases. It offers a full featured, easy and productive API. Written in ISO C on top of OCI, OCILIB runs on all Oracle platforms. Official website: http://www.ocilib.net/ Sourceforge project: http://sourceforge.net/projects/orclib/ Wikipedia: http://en.wikipedia.org/wiki/OCILIB
Re: Oracle Database - ocilib
On Thursday, 5 April 2012 at 17:58:15 UTC, Walter Bright wrote: https://github.com/D-Programming-Deimos/ocilib Thank you.
Re: Oracle Database - ocilib
On Tuesday, 3 April 2012 at 04:01:07 UTC, dnewbie wrote: It also works on Linux (I've just tested it on Debian Squeeze with Oracle Express) Rock'n'roll! Hi. I'd like to submit these bindings to be reviewed for inclusion in Deimos.
Re: Oracle Database - ocilib
It also works on Linux (I've just tested it on Debian Squeeze with Oracle Express) Rock'n'roll!
Oracle Database - ocilib
I've added oracle binding (ocilib). It was tested on Windows with Oracle Express Edition. http://my.opera.com/run3/blog/2012/04/02/d-oracle
Re: Poll of the week - How long have you been in the D world?
On Friday, 30 March 2012 at 22:17:55 UTC, Stewart Gordon wrote: I see that the numbers are almost evenly balanced between the four categories. But does this really mean that we've attracted more people in the last two years than in all earlier years combined, or that an awful lot of old-timers have left? I want to believe that this is like a critical mass ready to explode :) It would be good to do the poll again each year and see how the numbers compare. Stewart.
Re: Linux and D wallpaper :)
On Thursday, 29 March 2012 at 04:48:39 UTC, F i L wrote: http://reign-studios.com/d-wallpapers/LinuxAndD.png Very nice. Thanks!!
Re: D web apps: cgi.d now supports scgi
Thanks for doing this (and the other misc stuff) I wonder how can I generate unique, non predictable session ids.
Re: D web apps: cgi.d now supports scgi
On Sunday, 25 March 2012 at 19:22:02 UTC, Adam D. Ruppe wrote: On Sunday, 25 March 2012 at 19:14:32 UTC, dnewbie wrote: I wonder how can I generate unique, non predictable session ids. In web.d, there's a Session class that generates them with std.random.uniform. I suspect this isn't the best possible, but it's worked pretty well so far. The session class also uses a file to store persistent string key/value data. This is what I was looking for. Rock'n'roll!!
Re: D web apps: cgi.d now supports scgi
I can't compile web.d Notice: As of Phobos 2.055, std.date and std.dateparse have been deprecated. They will be removed in February 2012. Please use std.datetime instead. arsd\web.d(2671): Error: function std.date.dateFromTime is deprecated arsd\web.d(2672): Error: function std.date.yearFromTime is deprecated arsd\web.d(2673): Error: function std.date.monthFromTime is deprecated
Poll of the week - How long have you been in the D world?
Just out of curiosity, is D attracting new users? Are the old users running? Place your vote here http://www.easypolls.net/poll.html?p=4f6fb7e5e4b04f389e5eb66f
Re: Mono-D@GSoC - Mentor needed
On Tuesday, 20 March 2012 at 22:52:13 UTC, James Miller wrote: A bit of a side note, but is there any way that some of this work could be made more standalone, even if somebody else has to take up the work to finish it and make it truly standalone. I personally can't stand fully integrated environments, but I do like things like code completion and the like, so it would be nice to be able to use these features in, for example, vim. I don't know how feasible this is, but it's worth mentioning. -- James Miller Yes!! I want a standalone version too. I like Mono-D very much, however, not being able to type the ~ key in MonoDevelog is really annoying.
Re: StackOverflow Chat Room
I need 20 reputation. Please help me. On Wed, Mar 21, 2012, at 12:23 PM, Robik wrote: On Sunday, 18 March 2012 at 23:13:47 UTC, James Miller wrote: Hey guys, I made a StackOverflow chat room. You don't have to use it or anything, but at least it exists now. Its called Dlang, http://chat.stackoverflow.com/rooms/9025/dlang -- James Miller Awesome. But it needs to be configured. What's your IRC name(need to talk about it)?
Re: Converting C .h Files to D Modules
On Wednesday, 21 March 2012 at 01:09:58 UTC, Andrej Mitrovic wrote: On 3/21/12, Pedro Lacerda kanvua...@gmail.com wrote: Ouch, void* is the same in both languages, sorry. I addressed a new problem: typedef struct SomeFunctions { void *(*funcA)(char*, size_t); void *(*funcB)(void); } SomeFunctions; How do I convert that functions references into an D struct? extern(C) struct SomeFunctions { void function(char*, size_t) funcA; void function() funcB; } Use HTOD (http://dlang.org/htod.html) if you can to convert .h to .D (it's Windows-only but might be usable via Wine). Why not void* function(char*, size_t) funcA; void* function() funcB;
mysql tool
Hi D friends. I'd like to share with you a little tool. It allows you to execute SQL statements in your MySQL database. It displays the data in a nice data grid widget written by David Hillard. I hope you like it. Link http://my.opera.com/run3/blog/2012/03/17/mysql-tool
Re: D port of dmd: Lexer, Parser, AND CodeGenerator fully operational
Zach the Mystic - I can't compile it. dmd\binExp.d(115): Error: function dmd.binExp.AndAndExp.isBit of type bool() overrides but is no t covariant with dmd.expression.Expression.isBit of type int() dmd\binExp.d(115): Error: function dmd.binExp.AndAndExp.isBit does not override any function On Wed, Mar 7, 2012, at 10:09 PM, Zach the Mystic wrote: On Wednesday, 7 March 2012 at 21:06:25 UTC, Zach the Mystic wrote: On Wednesday, 7 March 2012 at 20:46:40 UTC, Andrej Mitrovic wrote: Hi, which version of the compiler can this be built with? I get this with 2.058: dmd\binExp.d(324): Error: function dmd.binExp.EqualExp.isBit of type bool() overrides but is not covariant with dmd.expression.Expression.isBit of type int() dmd\binExp.d(324): Error: function dmd.binExp.EqualExp.isBit does not override any function Well, I was using 2.057 But obviously you've found a bug I can fix rather quickly! OK I think it's fixed. Zach
Re: D port of dmd: Lexer, Parser, AND CodeGenerator fully operational
It's working.. Pretty cool :) On Thu, Mar 8, 2012, at 12:07 AM, Zach the Mystic wrote: On Wednesday, 7 March 2012 at 21:15:46 UTC, dnewbie wrote: Zach the Mystic - I can't compile it. Still not working?
htod - const
I have this file tmp.h: const char *getvalue(const char *key); I run htod tmp.h and I've got the output --- /* Converted to D from tmp.h by htod */ module tmp; //C const char *getvalue(const char *key); extern (C): char * getvalue(char *key); --- Why is 'const' removed?
Re: htod - const
Thanks Trass3r. On Tue, Mar 6, 2012, at 05:50 PM, Trass3r wrote: Why is 'const' removed? cause htod sucks. D1 didn't have const and htod wasn't updated for ages.
Re: std.socket with GDC
On Sat, Feb 25, 2012, at 10:38 PM, Mars wrote: On Saturday, 25 February 2012 at 18:27:29 UTC, Vladimir Panteleev wrote: On Friday, 24 February 2012 at 19:15:26 UTC, Mars wrote: Hello everybody. When trying to compile a program using GDC (Windows), which includes an import std.socket, I get a lot undefined references, like undefined reference to `WSAGetLastError@0' Try linking with libws2_32.a. Still the same. Does that work for you? std.socket works for me, gdc64 (windows)
Re: Examples of Windows services in D?
Here is a simple service in D http://my.opera.com/run3/blog/2012/02/23/windows-services-in-d It's basically c translated to d. On Tue, Feb 21, 2012, at 03:08 PM, Graham Fawcett wrote: Hi folks, I've got a Windows service that I'd like to write in D, if possible. I see that Andrej Mitrovic has provided a binding for the relevant parts of the Windows API (thanks!): https://github.com/AndrejMitrovic/DWinProgramming/blob/master/win32/ winsvc.d Has anyone used this (or another binding) to write an actual service? Particularly, I was hoping to find a base class that takes care of common tasks (installing, removing, starting, etc.). Thanks! Graham
Re: Socket: The connection was reset
nrgyzer, please check the return value of 'receive'. http://dlang.org/phobos/std_socket.html#receive On Fri, Feb 10, 2012, at 02:06 PM, nrgyzer wrote: Works perfectly, thanks :) But... how can I read the complete HTTP-header? When I try the following: string header; ubyte[1024] buffer; while (cs.receive(buffer)) header ~= buffer; ... it works as long as the header doesn't have a length like 1024, 2048, 3072... Otherwise cs.receive() blocks forever and the server doesn't respond anything. Is there any solution how to prevent/solve this problem? == Auszug aus DNewbie (r...@myopera.com)'s Artikel Try this while(true) { Socket cs = s.accept(); cs.receive(new byte[1024]); cs.sendTo(HTTP/1.1 200 OK\r\nContent-Length: 11\r\n\r\nHello World); cs.close(); } On Thu, Feb 9, 2012, at 07:31 PM, Nrgyzer wrote: Hi guys, I wrote the following few lines: private { import std.socket; } void main() { Socket s = new TcpSocket(); s.bind(new InternetAddress(80)); s.listen(0); while(true) { Socket cs = s.accept(); cs.sendTo(HTTP/1.1 200 OK\r\nContent-Length: 11\r\n\r\nHello World); cs.close(); } s.close(); } The code compiles successfully and I also the server also responses with Hello World, but when I reload the page I sometimes get the following error (Firefox): The connection was reset - I also often get the same error in other browsers. Is there anything wrong with the code? Thanks in advance! -- D
Re: Socket: The connection was reset
Try this while(true) { Socket cs = s.accept(); cs.receive(new byte[1024]); cs.sendTo(HTTP/1.1 200 OK\r\nContent-Length: 11\r\n\r\nHello World); cs.close(); } On Thu, Feb 9, 2012, at 07:31 PM, Nrgyzer wrote: Hi guys, I wrote the following few lines: private { import std.socket; } void main() { Socket s = new TcpSocket(); s.bind(new InternetAddress(80)); s.listen(0); while(true) { Socket cs = s.accept(); cs.sendTo(HTTP/1.1 200 OK\r\nContent-Length: 11\r\n\r\nHello World); cs.close(); } s.close(); } The code compiles successfully and I also the server also responses with Hello World, but when I reload the page I sometimes get the following error (Firefox): The connection was reset - I also often get the same error in other browsers. Is there anything wrong with the code? Thanks in advance! -- D
Re: i18n
On Fri, Feb 3, 2012, at 09:48 PM, Trass3r wrote: Thanks a lot, So I just need to detect user locale using How to do that? You can always use the functions you would use in C. You can see your language id in this page: http://msdn.microsoft.com/en-us/library/dd318693(v=vs.85).aspx Example - import std.stdio; import std.c.windows.windows; alias DWORD LCID; extern (Windows) LCID GetSystemDefaultLCID(); int main() { LCID lcid = GetSystemDefaultLCID(); printf(GetSystemDefaultLCID = 0x%04X\n, lcid); switch (lcid) { case 0x0409: writeln(United States (US)); break; case 0x040c: writeln(France (FR)); break; default: writeln(Unknown); break; } return 0; } -
Re: MySQL
On Sun, Jan 22, 2012, at 12:11 AM, Ali Çehreli wrote: On 01/21/2012 06:28 PM, Mars wrote: On Sunday, 22 January 2012 at 00:50:28 UTC, Ali Çehreli wrote: Are you also including the library on the command line with -L-l? For example, for ncurses: dmd ... -L-lncurses ... And if needed, also -L-L to specify the location of library files for the linker. Ali Yes, I am including it. Tried pragma and command line. And I don't get a message that the lib couldn't be found. What exactly is -L-l supposed to do? Is this valid in DMD 2.057? I get an error with it (Unknown Option). Mars -L is dmd's the linker flag option. Anything after that is passed to the linker. So -L-l passes -l to the linker: http://www.d-programming-language.org/dmd-linux.html Ali I've took a look at MySQL headers, the functions use __stdcall, but in libmysql.dll exports table they are not decorated.
Re: MySQL
On Sun, Jan 22, 2012, at 01:13 PM, Mars wrote: On Sunday, 22 January 2012 at 10:21:29 UTC, DNewbie wrote: I've took a look at MySQL headers, the functions use stdcall, but in libmysql.dll exports table they are not decorated. This means...? Shouldn't it at least compile, if they are listed in the def file, coming from the lib? You should add 'extern(Windows)', but it would not work anyway. Can someone confirm the oplink does not handle this type of module (undecorated stdcall functions)?
Re: MySQL
On Sun, Jan 22, 2012, at 11:02 PM, DNewbie wrote: On Sun, Jan 22, 2012, at 01:13 PM, Mars wrote: On Sunday, 22 January 2012 at 10:21:29 UTC, DNewbie wrote: I've took a look at MySQL headers, the functions use stdcall, but in libmysql.dll exports table they are not decorated. This means...? Shouldn't it at least compile, if they are listed in the def file, coming from the lib? You should add 'extern(Windows)', but it would not work anyway. Can someone confirm the oplink does not handle this type of module (undecorated stdcall functions)? You can try // - libmysql.def --- LIBRARY libmysql.dll EXETYPE NT SUBSYSTEM WINDOWS EXPORTS _mysql_init@4=mysql_init // // --- mysqltest.d import libmysql; alias void MYSQL; int main() { MYSQL *m = libmysql.mysql_init(null); return 0; } // --- // --- libmysql.di --- alias void MYSQL; export extern (Windows) MYSQL *mysql_init(MYSQL *); // $ implib /system libmysql.lib libmysql.def $ dmd mysqltest.d libmysql.lib It works..
Re: MySQL
Please check whether your MySQL lib is 64 bit and your app is 32 bit. On Sat, Jan 21, 2012, at 10:38 PM, Mars wrote: Hello everyone. I've been trying to use MySQL in an application on Windows, but I always get Symbol Undefined _mysql_init I've put the lib in the correct folder, so I don't know what the problem might be. I've tried several libs, and tried to compile it myself (always converted using coffimplib), but it fails, no matter what. I've also tried to make a def file out of the lib, and the functions are definitly listed as exports there. Any idea what I might doing wrong? Mars -- D
Re: OOP Windows
On Mon, Jan 16, 2012, at 05:59 PM, Andrej Mitrovic wrote: On 1/16/12, Robert Clipsham rob...@octarineparrot.com wrote: https://github.com/AndrejMitrovic/DWinProgramming I think he's looking for an OOP approach, that code is basically C translated to D. There are some OOP libraries he can use, like DGUI or DFL. And there are some OOP wrappers for WinAPI somewhere (probably on dsource). Maybe http://pr.stewartsplace.org.uk/d/sdwf/ or http://www.dsource.org/projects/minwin. I think these two might be slightly outdated by now though. Yes. I know a bit of C (not C++) and the Windows API. Now I'd like to learn more about OOP. That's what I've found so far, both are for C++ programmers http://win32-framework.sourceforge.net/ http://relisoft.com/win32/ Wel..I'm not sure. Should I learn C++ before D? Thank you everybody.
OOP Windows
Is there a D version of this type of tutorial? https://www.relisoft.com/win32/index.htm