Re: argument type const char* can pass string, buf why const wchar* can not pass wstring

2015-12-26 Thread Jimmy Cao via Digitalmars-d-learn
On Sunday, 27 December 2015 at 03:34:18 UTC, riki wrote: void ccf(const char* str){} void cwf(const wchar* str){} void main() { ccf("aaa");//ok cwf("xxx"w); // error and why ? } You need to remove the w suffix. Otherwise it is forcibly typed as a dynamic array and is no longer im

Re: etc.c.curl...?

2012-01-10 Thread Jimmy Cao
There's a wrapper for it that will be included in Phobos. This wrapper is easier to work with for D. It has structs for HTTP, FTP and SMTP. https://github.com/jcd/phobos/blob/curl-wrapper/etc/curl.d 2012/1/10 simendsjo > Anyone using this module? > For a complete curl newbie, it's far from s

Re: Transferring global variables from D to C

2011-10-01 Thread Jimmy Cao
I'm not sure. Try __gshared string str = "a"; 2011/10/1 Dainius (GreatEmerald) > > However, this gets quite inefficient with a lot of different strings, > > I just had an idea, perhaps it's possible to work around this > particular point by creating a wrapper function that converts the > passed

Re: copy and paste in program

2011-09-12 Thread Jimmy Cao
The other way is a bit more complicated. Try this: import std.stdio; import core.stdc.string; import std.string; extern(Windows) { bool OpenClipboard(void*); void* GetClipboardData(uint); void* SetClipboardData(uint, void*); bool EmptyClipboard(); bool CloseClipboard(); void* Gl

Re: copy and paste in program

2011-09-11 Thread Jimmy Cao
Here's an example I've quickly put together for you: import std.stdio; import core.stdc.string; extern(Windows) { void* GetClipboardData(uint); bool OpenClipboard(void*); } void main() { if (OpenClipboard(null)) { auto cstr = cast(char*)GetClipboardData(1); if (cstr)

Re: copy and paste in program

2011-09-11 Thread Jimmy Cao
Well, it doesn't matter what you've used in the past :-) Take a look: http://msdn.microsoft.com/en-us/library/ms907128.aspx On Sun, Sep 11, 2011 at 5:29 PM, Joel Christensen wrote: > Hi, > > I've got a text program I'm working on. It has game like print. But I want > to be able to copy to the

Re: byte* and int length -> byte[]

2011-08-15 Thread Jimmy Cao
On Mon, Aug 15, 2011 at 12:16 PM, mimocrocodil <4deni...@gmail.com> wrote: > I obtain immutable(byte)* and int where contained length of bytes block > from C library. > > Can I convert this into byte[] without explict copying etc. > > Something like: > > byte* p; // bytes > int size; // size of by

Re: exe-Icon

2011-08-01 Thread Jimmy Cao
Yes, add it as an ICON resource. In a .rc file: 100 ICON "icon.ico" Then compile the resource file with your favorite resource compiler. Then pass the .res file as an argument to dmd. On Mon, Aug 1, 2011 at 10:27 AM, Nrgyzer wrote: > Hi guys, > > the most applications using there own icons for

Re: calling D2 routines from C routines on linux

2011-07-19 Thread Jimmy Cao
Oh, I see. That's very convenient. On Wed, Jul 20, 2011 at 12:04 AM, Andrej Mitrovic < andrej.mitrov...@gmail.com> wrote: > On 7/20/11, Jimmy Cao wrote: > > What? I've never needed to do that when compiling programs with > > -L/exet:nt/su:windows:4.0 > >

Re: calling D2 routines from C routines on linux

2011-07-19 Thread Jimmy Cao
On Tue, Jul 19, 2011 at 6:48 PM, Andrej Mitrovic wrote: > > This is similar to how it's done for Windows GUI applications, where > we have to manually run the initialize function in druntime (unless > it's hidden by some GUI framework). > What? I've never needed to do that when compiling progra

Re: Interfacing to C

2011-06-28 Thread Jimmy Cao
On Tue, Jun 28, 2011 at 11:15 PM, Joshua Niehus wrote: > Hello, > > I was trying to run the example on the Interfacing to C page ( > http://www.d-programming-language.org/interfaceToC.html) and ran into few > issues. To get it to work "as is" i was .dup(ing) strings into new chars > with defined

Re: Interfacing to C. extern (C) variables

2011-06-26 Thread Jimmy Cao
On Sun, Jun 26, 2011 at 5:00 PM, Alex_Dovhal wrote: > "Robert Clipsham" wrote: > > On 26/06/2011 20:54, Alex_Dovhal wrote: > >> I'd like to call C functions and use C variables in D module. > >> D calls C functions just fine, but how can I use C variables? > > > > extern(C) extern int myCVar; >

Re: Convert const(GUID)* to GUID*

2011-06-25 Thread Jimmy Cao
On Sat, Jun 25, 2011 at 2:48 PM, Loopback wrote: > Hello! > > I've recently been working with DirectInput using the win32 API Binding > at dsource.org. This wrapper has been working perfectly fine until I > started using GUID constants defined in win32.directx.dinput8. > > The directx function Di

Re: Remove all elements in an associative array

2011-06-24 Thread Jimmy Cao
On Fri, Jun 24, 2011 at 10:41 PM, Nub Public wrote: > Is there a way to remove all elements in an associative array? > > I tried clear() but it doesn't work. For some reason it sets the length of > the array to gibberish. What does clear() do exactly? > This same thing was asked many years ago:

Re: readf with strings

2011-06-22 Thread Jimmy Cao
On Wed, Jun 22, 2011 at 1:31 PM, Ali Çehreli wrote: > On Wed, 22 Jun 2011 20:17:39 +0200, Andrej Mitrovic wrote: > > > This library has some nice user-input methods for D2: > > https://github.com/he-the-great/JPDLibs/tree/cmdln > > Thanks! :) > > The Turkish D community has experimented with a si

Re: An effort at creating a free ebook for learning D

2011-06-22 Thread Jimmy Cao
I've done some major restructuring to the ebook. Now, the link to the first lesson is: http://en.wikibooks.org/wiki/D_(The_Programming_Language)/d2/Phobos/Lesson_1 There are 7 lessons currently. Lesson 3 (Functions) and 9 (Slicing) are not written as of now. If you contribute, please add yourself

Re: An effort at creating a free ebook for learning D

2011-06-20 Thread Jimmy Cao
On Mon, Jun 20, 2011 at 5:13 PM, Kai Meyer wrote: > On 06/20/2011 03:46 PM, Jose Armando Garcia wrote: > >> On Mon, Jun 20, 2011 at 6:30 PM, Jimmy Cao wrote: >> >>> I helped with something last summer: an attempt at creating a wikibook >>> for >>> &g

Re: An effort at creating a free ebook for learning D

2011-06-20 Thread Jimmy Cao
On Mon, Jun 20, 2011 at 4:46 PM, Jose Armando Garcia wrote: > Good idea. Small notes: > > *) In the tip section 'write("Hello\n") and writeln("Hello")' are not > the same. writeln and writefln flush. write doesn't. > *) Not sure if you want to also encourage portable code. "\n" should > be replace

An effort at creating a free ebook for learning D

2011-06-20 Thread Jimmy Cao
I helped with something last summer: an attempt at creating a wikibook for D. At that time, my D skills were very bad, so I had to concentrate on learning D first before contributing to more lessons. One thing that has always bothered me is, there aren't many good *free* ebooks for learning D. We

Anybody want to help this Haskell programmer out about type classes?

2011-06-16 Thread Jimmy Cao
http://stackoverflow.com/questions/6328444/type-classes-in-d This guy seems to be very optimistic about D's functional possibilities. Unfortunately, the only answer there right now is a generic ramble concerning D.

Re: status of shared-libs on Windows?

2011-05-19 Thread Jimmy Cao
I've even created a dll that is used as a keylogger hook thing for Windows with only D.

Re: implib

2011-04-12 Thread Jimmy Cao
It's for Windows only.

Re: (coff)-Implib lib from dll

2011-01-15 Thread Jimmy Cao
Try this: implib /s libmysql.lib libmysql.dll Then change extern(Windows) to extern(C). (That's how I usually have it set up)

Re: D Language info collected and combined into one CHM file.

2011-01-07 Thread Jimmy Cao
Maybe it's too big. Just post a download link.