Re: How array concatenation works... internally

2018-04-23 Thread Dnewbie via Digitalmars-d-learn
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

2018-04-23 Thread Dnewbie via Digitalmars-d-learn
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

2018-04-23 Thread Dnewbie via Digitalmars-d-learn
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" ~

Re: Question about function aliases

2013-12-11 Thread dnewbie
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 c

Re: Getting the missing Windows functions

2013-10-08 Thread dnewbie
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 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 W

Re: How to cleanup after Socket.bind on Linux?

2013-08-26 Thread dnewbie
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: DLLs: Cleaning up

2013-07-11 Thread dnewbie
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 crash

Re: x64 Link Issues - Can someone please help?

2013-04-19 Thread dnewbie
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: Trouble with DLL address

2013-01-14 Thread dnewbie
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= LoadLibrar

Trouble with DLL address

2013-01-14 Thread dnewbie
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 int __stdcall RealFunctio

Re: #define trouble

2012-11-27 Thread dnewbie
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

#define trouble

2012-11-26 Thread dnewbie
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

Re: Using MinGW DLL with DMD?

2012-08-09 Thread dnewbie
There's an example: http://my.opera.com/run3/blog/2012/01/24/mixing-c-and-d-on-windows-part-1

Re: WinAPI LowLevel Keyboard Hooks

2012-07-19 Thread dnewbie
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

Re: WinAPI LowLevel Keyboard Hooks

2012-07-19 Thread dnewbie
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 th

Re: WinAPI LowLevel Keyboard Hooks

2012-07-19 Thread dnewbie
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 i

Re: WinAPI LowLevel Keyboard Hooks

2012-07-19 Thread dnewbie
You don't see the "WHOA" message? Try this alias HANDLE HHOOK;

Re: WinAPI LowLevel Keyboard Hooks

2012-07-19 Thread dnewbie
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

Re: Winamp plugin

2012-07-11 Thread dnewbie
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

2012-07-08 Thread dnewbie
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 t

Re: Winamp plugin

2012-07-05 Thread dnewbie
It works without error when compiled by GDC. Thanks.

Re: Winamp plugin

2012-07-05 Thread dnewbie
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

Winamp plugin

2012-07-04 Thread dnewbie
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 ---

Re: Build WindowsApi bindings with dmd?

2012-07-02 Thread dnewbie
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: function pointer when a function is overloaded.

2012-06-30 Thread dnewbie
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: Windows - ZeroMemory macro

2012-05-27 Thread dnewbie
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*)&am

Windows - ZeroMemory macro

2012-05-26 Thread dnewbie
In C I can write OPENFILENAME ofn; ZeroMemory(&ofn, sizeof(ofn)); In D, there is no ZeroMemory. Please help me.

Re: libraries and c++ compatibility

2012-05-13 Thread dnewbie
On Sunday, 13 May 2012 at 19:01:15 UTC, Jason King wrote: . C:\ocilib\ocilib3.9.3\lib32>dmc myapp.cpp -c -Ic:\ocilib\ocilib3.9.3\include C:\ocilib\ocilib3.9.3\lib32>optlink myapp.obj,,,ociliba-dm.lib OPTLINK (R) for Win32 Release 7.50B1 Copyright (C) Digital Mars 1989 - 2001 All Rights Reser

Re: libraries and c++ compatibility

2012-05-13 Thread dnewbie
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 -I -c, but I can't seem to figure out the right switch

Re: mysql binding/wrapper?

2012-04-29 Thread dnewbie
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: string concatenation

2012-04-08 Thread dnewbie
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

string concatenation

2012-04-07 Thread dnewbie
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) ~

Re: Converting C .h Files to D Modules

2012-03-20 Thread dnewbie
On Wednesday, 21 March 2012 at 01:09:58 UTC, Andrej Mitrovic wrote: On 3/21/12, Pedro Lacerda 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 d

Re: htod - const

2012-03-06 Thread dnewbie
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. >

htod - const

2012-03-06 Thread dnewbie
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); -

Re: std.socket with GDC

2012-02-25 Thread DNewbie
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 i

Re: Examples of Windows services in D?

2012-02-22 Thread DNewbie
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 Mitrov

Re: Socket: The connection was reset

2012-02-10 Thread DNewbie
On Fri, Feb 10, 2012, at 07:44 PM, nrgyzer wrote: > Yep, thanks... but I already checked out the return value and the problem > is "If the socket is blocking, receive waits until there is data to be > received.". The following > socket blocks and the server doesn't respond: > > while(true) { >

Re: Socket: The connection was reset

2012-02-10 Thread DNewbie
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]); > >

Re: Socket: The connection was reset

2012-02-09 Thread DNewbie
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

Re: i18n

2012-02-03 Thread DNewbie
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

Re: i18n

2012-02-03 Thread DNewbie
You can build multiple versions of you app: http://dsource.org/projects/tutorials/wiki/LocalesExample On Thu, Feb 2, 2012, at 07:48 PM, xancorreu wrote: > Hi, > > Is there any way for localizate and internationalizate messages? > I were shocked if D has something like Fantom > [http://fantom.or

Re: MySQL

2012-01-22 Thread DNewbie
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 expo

Re: MySQL

2012-01-22 Thread DNewbie
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...? > Shou

Re: MySQL

2012-01-22 Thread DNewbie
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 ... >

Re: MySQL

2012-01-21 Thread DNewbie
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

Re: OOP Windows

2012-01-16 Thread DNewbie
On Mon, Jan 16, 2012, at 05:59 PM, Andrej Mitrovic wrote: > On 1/16/12, Robert Clipsham 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

OOP Windows

2012-01-15 Thread DNewbie
Is there a D version of this type of tutorial? https://www.relisoft.com/win32/index.htm

Re: import std.c.windows.windows;

2012-01-14 Thread DNewbie
On Wed, Jan 11, 2012, at 01:16 PM, Mike Parker wrote: > On 1/10/2012 10:57 PM, DNewbie wrote: > > On Tue, Jan 10, 2012, at 10:37 PM, Mike Parker wrote: > >> > >> Those samples use a binding to the Win32 API[1] that does not ship with > >> DMD. So in your cas

Re: A tutorial on D templates

2012-01-14 Thread DNewbie
On Sat, Jan 14, 2012, at 09:07 AM, Philippe Sigaud wrote: > >> On 13/01/12 10:48 PM, DNewbie wrote: > >> > I can't understand it. Why would someone need template programming. What > >> > problem does template solve? > > Well read on and see :-)

Re: function pointer from DLL

2012-01-13 Thread DNewbie
On Sat, Jan 14, 2012, at 06:04 AM, Andrej Mitrovic wrote: > On 1/14/12, Andrej Mitrovic wrote: > > You can clone this: g...@github.com:AndrejMitrovic/DSciteWin.git > > > > Then just run build.bat. > > > > Sorry, I've assumed you run git, the http link is: > https://github.com/AndrejMitrovic/DSci

function pointer from DLL

2012-01-13 Thread DNewbie
I've been trying to translate the following from http://www.scintilla.org/Steps.html int (*fn)(void*,int,int,int); void * ptr; int canundo; fn = (int (__cdecl *)(void *,int,int,int))SendMessage( hwndScintilla,SCI_GETDIRECTFUNCTION,0,0); ptr = (void *)SendMessage(hwndScintilla,SCI_GETDIRE

Re: A tutorial on D templates

2012-01-13 Thread DNewbie
On Fri, Jan 13, 2012, at 11:28 PM, Peter Alexander wrote: > On 13/01/12 10:48 PM, DNewbie wrote: > > I can't understand it. Why would someone need template programming. What > > problem does template solve? > > Suppose you want to write a function to get the minimu

Re: A tutorial on D templates

2012-01-13 Thread DNewbie
I can't understand it. Why would someone need template programming. What problem does template solve? -- D

Re: import std.c.windows.windows;

2012-01-10 Thread DNewbie
On Tue, Jan 10, 2012, at 10:37 PM, Mike Parker wrote: > > Those samples use a binding to the Win32 API[1] that does not ship with > DMD. So in your case, std.c.windows.windows is probably what you want > for now. > > > [1]http://dsource.org/projects/bindings/wiki/WindowsApi > Ok.. I still do

import std.c.windows.windows;

2012-01-10 Thread DNewbie
I'm not sure I understand.. The page at http://dlang.org/windows.html says Instead of the: #include of C, in D there is: import std.c.windows.windows; However, the samples at https://github.com/AndrejMitrovic/DWinProgramming/tree/master/Samples use import win32.windef; import win32

Re: Mixing D and C - Windows

2012-01-02 Thread DNewbie
Resolved. Thanks everyone. On Tue, Jan 3, 2012, at 04:49 AM, Andrej Mitrovic wrote: > Maybe I'm wrong, but IIRC objconv won't work on import libs. > > But there are other ways to do it: http://support.microsoft.com/kb/131313 > -- D

Re: Mixing D and C - Windows

2012-01-02 Thread DNewbie
Thank you both. I've created a D DLL [http://dlang.org/dll.html], then I've loaded it from a C program [compiled with dmc]. However, I'd want to be able to call it from a C program compiled with MSVC, and I got a link error - unresolved external symbol [link testdll.obj /implib:mydll.lib /out:t

Mixing D and C - Windows

2011-12-31 Thread DNewbie
C program loads D dll or D program loads C dll Is it possible? -- D