Struggling with wchar[] to string conversion

2021-01-19 Thread Stefan via Digitalmars-d-learn
Hi, I am using dmd2.081.1 on windows building a 32 bit executable. I am trying to find out how many instances of the same program are running. Therefor I use the core.sys.windows.tlhelp32 module. With the CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0) and Process32First/Process32Next I

Re: Calling D code from C

2020-01-08 Thread Stefan via Digitalmars-d-learn
On Thursday, 26 May 2005 at 20:41:10 UTC, Vathix wrote: The problem is that D's main() initializes things. Using a C main() bypasses that startup code. Put the main() in the D file (with D extern) and have it call a function in the C file that you will treat as main. That's correct, but not

Re: CMake support for D

2018-05-30 Thread Stefan via Digitalmars-d-learn
On Tuesday, 27 February 2018 at 14:32:54 UTC, King_DuckZ wrote: ... My problem is mixing D with C and C++ ... you found already Dragos cmake-d, but not sure if you also know Dragos talk about mixing D with C/C++. If not, have a look:

Re: Code style for property

2017-03-12 Thread Stefan via Digitalmars-d-learn
On Sunday, 12 March 2017 at 10:47:35 UTC, Andrey wrote: Hello, how better to declare properties, for example I have class: class Foo { this(in int x, in int y, Bar bar) { this.x = x; this.y = y; this.bar = bar; } private: int x; int y; Bar bar; }

Re: Converting all enum members to a string fails with version 2.0.72.0

2016-11-29 Thread Stefan via Digitalmars-d-learn
On Monday, 21 November 2016 at 18:53:59 UTC, Stefan wrote: On Monday, 21 November 2016 at 17:26:37 UTC, Jonathan M Davis wrote: [...] Thanks Jonathan for the explanation. The cast works fine but feels "unsafe". I will wait for the next version. Stefan Version D 2.072.1 Beta fixed my

Re: Converting all enum members to a string fails with version 2.0.72.0

2016-11-21 Thread Stefan via Digitalmars-d-learn
On Monday, 21 November 2016 at 17:26:37 UTC, Jonathan M Davis wrote: [...] Thanks Jonathan for the explanation. The cast works fine but feels "unsafe". I will wait for the next version. Stefan

Converting all enum members to a string fails with version 2.0.72.0

2016-11-21 Thread Stefan via Digitalmars-d-learn
Before 2.0.72.0: import std.algorithm : map, joiner; import std.uni : toUpper; import std.traits : EnumMembers; import std.stdio : writeln; import std.conv: to; private enum Color : string { RED = "red", BLUE = "blue", YELLOW = "yellow" } void main(string[] args) { writeln( [

Re: Caesar Cipher Cracking

2016-08-14 Thread Stefan via Digitalmars-d-learn
same code, just a little shorter. usage of ".array" more UFCS replaced cast with ".to" ---8><--- import std.stdio, std.conv; import std.algorithm, std.algorithm.searching, std.range; import std.ascii, std.string : countchars; int let2int(char c)

Re: source/protocols.d(40, 34): Error: uninitialized variable 'value' cannot be returned from CTFE

2016-05-16 Thread Stefan via Digitalmars-d-learn
On Monday, 16 May 2016 at 11:13:52 UTC, ag0aep6g wrote: On 05/16/2016 11:24 AM, Stefan wrote: source/protocols.d(40,34): Error: uninitialized variable 'value' cannot be returned from CTFE Ouch. That's not a good error message. There is no `value` on that line. I've filed an issue:

source/protocols.d(40,34): Error: uninitialized variable 'value' cannot be returned from CTFE

2016-05-16 Thread Stefan via Digitalmars-d-learn
Hello, i try to port some go code to D i get this error messages from my current code. source/protocols.d(40,34): Error: uninitialized variable 'value' cannot be returned from CTFE source/protocols.d(41,34): Error: uninitialized variable 'value' cannot be returned from CTFE

Re: Socket - handling large numbers of incoming connections

2015-12-21 Thread Stefan via Digitalmars-d-learn
How about https://github.com/dcarp/asynchronous ? Asyncio Socket handling is sometimes quite nice. It's performance is okay for nearly no effort and the code looks clean. Details here: http://dcarp.github.io/asynchronous/asynchronous/streams/startServer.html vibe.d also offers a fiber based

Problem with map, reduce, ..

2015-06-24 Thread Stefan via Digitalmars-d-learn
I tried to refactor some existing code to use more of the functional patterns/style (map, filter, reduce, ..). The task is to read in some sort of a simple property file and present the result as an associative array. My attempt is: import std.stdio; import std.algorithm.iteration : filter,

Re: Problem with map, reduce, ..

2015-06-24 Thread Stefan via Digitalmars-d-learn
On Wednesday, 24 June 2015 at 08:33:29 UTC, Adrian Matoga wrote: On Wednesday, 24 June 2015 at 08:30:29 UTC, Adrian Matoga wrote: input.byLine() yields char[]'s as range elements, while props is (correctly) indexed by strings, i.e. immutable(char)[]. Ooops, more precisely it's because of the

Re: Problem with map, reduce, ..

2015-06-24 Thread Stefan via Digitalmars-d-learn
On Wednesday, 24 June 2015 at 09:35:35 UTC, Adrian Matoga wrote: On Wednesday, 24 June 2015 at 08:58:10 UTC, Stefan wrote: On Wednesday, 24 June 2015 at 08:33:29 UTC, Adrian Matoga wrote: [...] Thanks! That does it! Any idea how to make the 'ugly' reduce step more 'pleasant'? I.e. make it