Re: Whats the correct way to pass a D array type to a win32 api function wanting a buffer?

2017-07-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 13 July 2017 at 01:15:46 UTC, FoxyBrown wrote: auto EnumServices() I wouldn't use auto here. The reason you get mismatch types on return here since you don't return consistent types inside. ENUM_SERVICE_STATUS_PROCESS[5000] services; Are you sure you are getting the

Re: Whats the correct way to pass a D array type to a win32 api function wanting a buffer?

2017-07-12 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 13 July 2017 at 01:15:46 UTC, FoxyBrown wrote: Everything I do results in some problem, I've tried malloc but then converting the strings resulted in my program becoming corrupted. Heres the code: auto EnumServices() { auto schSCManager = OpenSCManager(null, null,

Whats the correct way to pass a D array type to a win32 api function wanting a buffer?

2017-07-12 Thread FoxyBrown via Digitalmars-d-learn
Everything I do results in some problem, I've tried malloc but then converting the strings resulted in my program becoming corrupted. Heres the code: auto EnumServices() { auto schSCManager = OpenSCManager(null, null, SC_MANAGER_ALL_ACCESS); if (NULL == schSCManager) {

Re: 2D game physics, macOS

2017-07-12 Thread Joel via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 12:05:33 UTC, Jacob Carlborg wrote: On 2017-07-12 12:18, Joel wrote: Is there a 2D physics library I can use on macOS, with D? I already use a multimedia library for graphics, sound and input. Box2D [1] perhaps. I think I've seen bindings for it, somewhere.

Re: Help me fix my compiler

2017-07-12 Thread Andrew Edwards via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 12:05:17 UTC, Namal wrote: Hello, I used the Install Script command line to install the newest dmd compiler (Ubuntu 16.04.2 LTS). Now I have to type 'source ~/dlang/dmd-2.074.1/activate' before I can use it and it is also not show in the software center like it

Re: Static array with parameter based size?

2017-07-12 Thread Jack Applegame via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 05:45:13 UTC, Miguel L wrote: Also what is it possible in D to write a function that accepts an static array of any size? void foo(size_t N)(ref int[N] arr) { ... } int[10] arr; foo(arr);

Re: Foreign threads in D code.

2017-07-12 Thread Igor Shirkalin via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 09:49:32 UTC, Guillaume Piolat wrote: On Tuesday, 11 July 2017 at 22:59:42 UTC, Igor Shirkalin wrote: [...] -- Biotronic Thanks for very useful information! Just one small note. If you don't know the foreign thread lifetime, it's cleaner to detach it from

Anything like quote?

2017-07-12 Thread Jean-Louis Leroy via Digitalmars-d-learn
I want to create a string while making sure it qualifies as an identifier. Like this: struct quote { static @property string opDispatch(string str)() { return str; } } unittest { assert(quote.foo == "foo"); } Does it already exist somewhere in the language or the library? J-L

Re: Having a strange issue with std.net.curl.HTTP as a struct dependency

2017-07-12 Thread crimaniak via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 13:47:06 UTC, Adam D. Ruppe wrote: This tells me the problem is in the collection order at the end of the program. ... So I'd say the answer is prolly to keep HTTP away from the GC. Manually free its arrays, or keep them outside arrays in the first place. I'd

Re: Struct Constructor Lazy

2017-07-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 11:18:08 UTC, Biotronic wrote: The traditional solution is static opCall: That's bug city... the dummy argument is better, or a named static factory function. Foo foo = Foo; Foo foo = Foo(); those are different with static opCall. It also conflicts with

Re: Struct Constructor Lazy

2017-07-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 11:57:33 UTC, Biotronic wrote: Debug = no optimization. That's not really true, you can have an optimized debug build. dmd's -debug, -g, and -O switches are all independent. -debug turns on blocks labeled with the `debug` switch in code. -g adds info for a

Re: Cannot dup an associative array but why?

2017-07-12 Thread Jean-Louis Leroy via Digitalmars-d-learn
On Tuesday, 11 July 2017 at 21:23:28 UTC, Ali Çehreli wrote: Default template and function arguments are resolved at instantiation site, which means __MODULE__ would resolve automatically to the caller's module. For example, if you have this module: __MODULE__ is a string so I cannot pass it

Re: Struct Constructor Lazy

2017-07-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 11:00:54 UTC, Jiyan wrote: when A(0) is called I would want here optimal performance, so there doesnt even need to be a value pushed on the stack (i=0), what would be like having a constructor with zero arguments (i is never used!). This is so, so irrelevant.

Re: Having a strange issue with std.net.curl.HTTP as a struct dependency

2017-07-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 10 July 2017 at 00:10:36 UTC, NoBigDeal256 wrote: The error goes away. The error also goes away if ThingA.arrayOfThingBs returns a single instance of ThingB instead of an array of ThingB. This tells me the problem is in the collection order at the end of the program. The HTTP

Re: Function with static array as parameter

2017-07-12 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 12:20:11 UTC, Miguel L wrote: What is the best way in D to create a function that receives a static array of any length? Do know that static arrays are passed by value in D, so passing a static array of a million elements will copy them... There are two

Re: Static array with parameter based size?

2017-07-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 05:45:13 UTC, Miguel L wrote: void f(int x) { int[] my_array; my_array.length=x; but I don't really need a dynamic array as length is not going to change inside f. Then just don't change the length... this is a correct way to do it. You could also allocate it

Re: Function with static array as parameter

2017-07-12 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 12:57:19 UTC, Rene Zwanenburg wrote: On Wednesday, 12 July 2017 at 12:20:11 UTC, Miguel L wrote: What is the best way in D to create a function that receives a static array of any length? Templatize the array length: void foo(size_t length)(int[length] arr) { }

Re: Function with static array as parameter

2017-07-12 Thread Biotronic via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 12:20:11 UTC, Miguel L wrote: What is the best way in D to create a function that receives a static array of any length? You will need to use templates: void foo(size_t N)(int[N] arr) { } -- Biotronic

Re: Function with static array as parameter

2017-07-12 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 12:20:11 UTC, Miguel L wrote: What is the best way in D to create a function that receives a static array of any length? Templatize the array length: void foo(size_t length)(int[length] arr) { }

Function with static array as parameter

2017-07-12 Thread Miguel L via Digitalmars-d-learn
What is the best way in D to create a function that receives a static array of any length?

Re: Foreign threads in D code.

2017-07-12 Thread Biotronic via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 12:08:35 UTC, Jacob Carlborg wrote: On 2017-07-12 11:28, Biotronic wrote: That's basically what I tried to say It wasn't very clear to me at least. Yeah, I see it in retrospect. "might collect memory that the thread is referencing on the stack or in non-GC

Re: Foreign threads in D code.

2017-07-12 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-07-12 11:28, Biotronic wrote: That's basically what I tried to say It wasn't very clear to me at least. - the GC may collect memory *it has allocated* if the only pointers to it are in memory the GC doesn't scan (i.e. on the stack of an unregistered thread or in memory not

Re: Struct Constructor Lazy

2017-07-12 Thread Biotronic via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 12:02:37 UTC, Jiyan wrote: Thank you, one last question: If i declare the parameter as ref i, then there shouldnt be any overhead wouldnt it? Thanks :) That would be basically the exact equivalent - instead of passing an int, you'll be passing a pointer. --

Re: 2D game physics, macOS

2017-07-12 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-07-12 12:18, Joel wrote: Is there a 2D physics library I can use on macOS, with D? I already use a multimedia library for graphics, sound and input. Box2D [1] perhaps. I think I've seen bindings for it, somewhere. [1] http://box2d.org -- /Jacob Carlborg

Help me fix my compiler

2017-07-12 Thread Namal via Digitalmars-d-learn
Hello, I used the Install Script command line to install the newest dmd compiler (Ubuntu 16.04.2 LTS). Now I have to type 'source ~/dlang/dmd-2.074.1/activate' before I can use it and it is also not show in the software center like it used to be. How can I fix it or how can I remove it?

Re: Struct Constructor Lazy

2017-07-12 Thread Jiyan via Digitalmars-d-learn
Thank you, one last question: If i declare the parameter as ref i, then there shouldnt be any overhead wouldnt it? Thanks :)

Re: Struct Constructor Lazy

2017-07-12 Thread Biotronic via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 11:34:45 UTC, Jiyan wrote: Hey, yes i did but to be honest i used dmd in debug version. The thing about the static one, is that it creates a local object A isnt that a performance issue itself - or am i wrong - im confused actually :P? Debug = no optimization.

Re: Struct Constructor Lazy

2017-07-12 Thread Jiyan via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 11:18:08 UTC, Biotronic wrote: On Wednesday, 12 July 2017 at 11:00:54 UTC, Jiyan wrote: [...] The traditional solution is static opCall: struct A { int field; static A opCall() { A result; result.field = getDataFromFile("file.txt");

Re: Struct Constructor Lazy

2017-07-12 Thread Biotronic via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 11:00:54 UTC, Jiyan wrote: Hey there:) i want to know whether the following is somehow possible: structs dont have default constructors, i know so: struct A { int field; this(int i){field = getDataFromFile("file.txt");} } A instance = A(0); Here comes my issue:

Struct Constructor Lazy

2017-07-12 Thread Jiyan via Digitalmars-d-learn
Hey there:) i want to know whether the following is somehow possible: structs dont have default constructors, i know so: struct A { int field; this(int i){field = getDataFromFile("file.txt");} } A instance = A(0); Here comes my issue: when A(0) is called I would want here optimal performance,

2D game physics, macOS

2017-07-12 Thread Joel via Digitalmars-d-learn
Is there a 2D physics library I can use on macOS, with D? I already use a multimedia library for graphics, sound and input.

Re: Foreign threads in D code.

2017-07-12 Thread Guillaume Piolat via Digitalmars-d-learn
On Tuesday, 11 July 2017 at 22:59:42 UTC, Igor Shirkalin wrote: On Tuesday, 11 July 2017 at 06:18:44 UTC, Biotronic wrote: On Monday, 10 July 2017 at 20:03:32 UTC, Igor Shirkalin wrote: [...] If DRuntime is not made aware of the thread's existence, the thread will not be stopped by the GC,

Re: Foreign threads in D code.

2017-07-12 Thread Biotronic via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 09:10:07 UTC, Jacob Carlborg wrote: On 2017-07-11 08:18, Biotronic wrote: If DRuntime is not made aware of the thread's existence, the thread will not be stopped by the GC, and the GC might collect memory that the thread is referencing on the stack or in non-GC

Re: Foreign threads in D code.

2017-07-12 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-07-11 08:18, Biotronic wrote: If DRuntime is not made aware of the thread's existence, the thread will not be stopped by the GC, and the GC might collect memory that the thread is referencing on the stack or in non-GC memory. Are you sure? Wouldn't that make malloc or any other

Re: Having a strange issue with std.net.curl.HTTP as a struct dependency

2017-07-12 Thread ketmar via Digitalmars-d-learn
ikod wrote: On Wednesday, 12 July 2017 at 08:24:12 UTC, NoBigDeal256 wrote: On Monday, 10 July 2017 at 20:55:19 UTC, ketmar wrote: NoBigDeal256 wrote: Do you happen to have a link to the bug report for this specific issue that I could look at? I looked at the known bugs list and couldn't

Re: Having a strange issue with std.net.curl.HTTP as a struct dependency

2017-07-12 Thread ikod via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 08:24:12 UTC, NoBigDeal256 wrote: On Monday, 10 July 2017 at 20:55:19 UTC, ketmar wrote: NoBigDeal256 wrote: Do you happen to have a link to the bug report for this specific issue that I could look at? I looked at the known bugs list and couldn't find anything

Re: How to add authentificaion method to request?

2017-07-12 Thread Cym13 via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 07:43:27 UTC, Suliman wrote: Compiler require libssl32.dll for run dlang-request based app. Where I can get it? I installed, OpenSSL, but can't find this lib in C:\OpenSSL-Win64 I don't use windows so it's nothing definitive but I'd bet that the "32" in

Re: Having a strange issue with std.net.curl.HTTP as a struct dependency

2017-07-12 Thread NoBigDeal256 via Digitalmars-d-learn
On Monday, 10 July 2017 at 20:55:19 UTC, ketmar wrote: NoBigDeal256 wrote: Do you happen to have a link to the bug report for this specific issue that I could look at? I looked at the known bugs list and couldn't find anything related to this. nope. it is a kind of "known bug nobody

Re: How to add authentificaion method to request?

2017-07-12 Thread Suliman via Digitalmars-d-learn
Compiler require libssl32.dll for run dlang-request based app. Where I can get it? I installed, OpenSSL, but can't find this lib in C:\OpenSSL-Win64