Re: unique_ptr | Unique for autoclose handle

2022-12-14 Thread Vitaliy Fadeev via Digitalmars-d-learn
On Wednesday, 14 December 2022 at 17:44:05 UTC, Ali Çehreli wrote: On 12/14/22 09:41, Ali Çehreli wrote: > // According to documentation, the handler must be created dynamically: > // We make a unique owner for it: Last try is customized **std.typecons.Unique**: ``` module safehandle

Re: unique_ptr | Unique for autoclose handle

2022-12-14 Thread Vitaliy Fadeev via Digitalmars-d-learn
On Wednesday, 14 December 2022 at 17:41:07 UTC, Ali Çehreli wrote: On 12/14/22 05:58, Vitaliy Fadeev wrote: > On Wednesday, 14 December 2022 at 11:30:07 UTC, Vitaliy Fadeev wrote: >> How to define HANDLE var ? What to return from procedure? How to call >> CloseHandle( h ) when variable destroyed

Re: How to compiler dlang code on Apple M1?

2022-12-14 Thread Sergey via Digitalmars-d-learn
On Tuesday, 13 December 2022 at 15:21:41 UTC, Steven Schveighoffer wrote: On 12/13/22 10:20 AM, Steven Schveighoffer wrote: Yeah, that's a known issue: https://github.com/ldc-developers/ldc/issues/3864 Try building with `-b plain` to avoid the debug build Oh, also, I have MACOSX_DEPLOYMENT_T

Re: unique_ptr | Unique for autoclose handle

2022-12-14 Thread Ali Çehreli via Digitalmars-d-learn
On 12/14/22 09:41, Ali Çehreli wrote: > // According to documentation, the handler must be created dynamically: > // We make a unique owner for it: Ignore that part. It's a leftover from my experiments with Unique!Handle. Ali

Re: unique_ptr | Unique for autoclose handle

2022-12-14 Thread Ali Çehreli via Digitalmars-d-learn
On 12/14/22 05:58, Vitaliy Fadeev wrote: > On Wednesday, 14 December 2022 at 11:30:07 UTC, Vitaliy Fadeev wrote: >> How to define HANDLE var ? What to return from procedure? How to call >> CloseHandle( h ) when variable destroyed? An obvious way is an RAII type where the destructor calls CloseHa

Re: unique_ptr | Unique for autoclose handle

2022-12-14 Thread Vitaliy Fadeev via Digitalmars-d-learn
On Wednesday, 14 December 2022 at 11:30:07 UTC, Vitaliy Fadeev wrote: How to define HANDLE var ? What to return from procedure? How to call CloseHandle( h ) when variable destroyed? I was trying **std.typecons.Unique**. But where I must put **CloseHandle( h )** ? I was trying **std.typecons.U

Re: unique_ptr | Unique for autoclose handle

2022-12-14 Thread Leonardo via Digitalmars-d-learn
On Wednesday, 14 December 2022 at 11:30:07 UTC, Vitaliy Fadeev wrote: Hi! I open a device under Windows: ``` HANDLE h = CreateFileW( ... ); ``` in procedure: ``` HANDLE open_keyboard_device2( LPCWSTR path, int* error_number ) { ... HANDLE dev_handle = CreateFileW(

Re: How to use version in dub?

2022-12-14 Thread Leonardo via Digitalmars-d-learn
On Tuesday, 13 December 2022 at 20:35:28 UTC, ryuukk_ wrote: On Tuesday, 13 December 2022 at 20:01:40 UTC, torhu wrote: On Tuesday, 13 December 2022 at 19:50:15 UTC, torhu wrote: On Tuesday, 13 December 2022 at 19:28:44 UTC, Leonardo A wrote: Hello. How to use version in dub? https://dlang.or

Re: unique_ptr | Unique for autoclose handle

2022-12-14 Thread Sergey via Digitalmars-d-learn
On Wednesday, 14 December 2022 at 11:30:07 UTC, Vitaliy Fadeev wrote: Teach me the most beautiful way. How to make beautiful? Thanks! Just for information there is a library that also could be helpful https://code.dlang.org/packages/autoptr

Re: gcc -E -dD; dstep; sqlite3

2022-12-14 Thread Siarhei Siamashka via Digitalmars-d-learn
On Thursday, 8 December 2022 at 14:28:02 UTC, johannes wrote: doing the following : (sqlite3 version 340) gcc -E -dD sqlite3ext.h > sqlite3ext.i dstep sqlit3ext.i -o/we/sqlite3/package.d when compiling a program using this interface (import we.sqlite3), I receive Errors like : [...]