Re: Vibe.d v0.9.0, v0.10.0: ` dub init hello -t vibe.d` fails to build on MacOS

2024-07-07 Thread Ki Rill via Digitalmars-d-learn
On Sunday, 7 July 2024 at 23:33:59 UTC, Steven Schveighoffer wrote: openssl version should be automatically determined by running a pre-build step. If this doesn't work for you, please file a bug here: https://github.com/D-Programming-Deimos/openssl -Steve Filed a bug here: https://github.

Re: Vibe.d v0.9.0, v0.10.0: ` dub init hello -t vibe.d` fails to build on MacOS

2024-07-07 Thread Ki Rill via Digitalmars-d-learn
On Sunday, 7 July 2024 at 11:33:47 UTC, Sergey wrote: On Sunday, 7 July 2024 at 10:55:21 UTC, Ki Rill wrote: Machine: ``` MacBook Pro (Retina, 15-inch, Late 2013), macOS Big Sur version 11.7.10 ``` How should I solve this? It mentions undefined symbols from openssl, but I have it installed.

Re: Operator "+=" overloading for class?

2023-12-20 Thread Ki Rill via Digitalmars-d-learn
On Wednesday, 20 December 2023 at 02:56:24 UTC, Steven Schveighoffer wrote: Instead you are trying to reassign the `this` reference, which is a local (and also forbidden). Think about it a second, your `this + rhs` is going to allocate a *new* object. Then if the assignment to the local `this`

Re: Operator "+=" overloading for class?

2023-12-18 Thread Ki Rill via Digitalmars-d-learn
On Monday, 18 December 2023 at 04:49:53 UTC, novice2 wrote: On Monday, 18 December 2023 at 03:39:16 UTC, Ki Rill wrote: On Sunday, 17 December 2023 at 07:05:12 UTC, Adam D. Ruppe wrote: On Sunday, 17 December 2023 at 04:13:20 UTC, Ki Rill wrote: [...] check what `op` is. pretty sure it is "+

Re: Operator "+=" overloading for class?

2023-12-17 Thread Ki Rill via Digitalmars-d-learn
On Sunday, 17 December 2023 at 07:05:12 UTC, Adam D. Ruppe wrote: On Sunday, 17 December 2023 at 04:13:20 UTC, Ki Rill wrote: [...] check what `op` is. pretty sure it is "+" not "+=" so your element isnt' saved anywhere. also a bit iffy there isn't a member here to work on Yes, op is '+'.

Re: Operator "+=" overloading for class?

2023-12-16 Thread Ki Rill via Digitalmars-d-learn
On Sunday, 17 December 2023 at 04:15:02 UTC, Ki Rill wrote: On Sunday, 17 December 2023 at 04:13:20 UTC, Ki Rill wrote: I am trying to overload `opOpAssign` for my class. The code [...] I forgot to mention, it is relevant to [`Value`](https://github.com/rillki/tiny-grad/blob/main/source/rk/

Re: Operator "+=" overloading for class?

2023-12-16 Thread Ki Rill via Digitalmars-d-learn
On Sunday, 17 December 2023 at 04:13:20 UTC, Ki Rill wrote: I am trying to overload `opOpAssign` for my class. The code [...] I forgot to mention, it is relevant to [`Value`](https://github.com/rillki/tiny-grad/blob/main/source/rk/tgrad/core/value.d) class only.

Operator "+=" overloading for class?

2023-12-16 Thread Ki Rill via Digitalmars-d-learn
I am trying to overload `opOpAssign` for my class. The code compiles, but it does not seem to be working. ```d // binary operations have already been implemented for Value // i need +=, -=, *=, /= auto opOpAssign(string op)(Value rhs) { mixin("return this" ~ op ~ "rhs;"); } auto opOpAssign(

Re: DlangUI: how to change AppFrames?

2023-10-26 Thread Ki Rill via Digitalmars-d-learn
On Tuesday, 24 October 2023 at 11:23:05 UTC, GrimMaple wrote: I think there was some kind of issue when changing widgets like that. Please try doing this instead: ```d window.executeInUiThread(() => window.mainWidget = myPreviousFrame); ``` Also, please post whole code so maybe I can fix this

Re: DlangUI: how to change AppFrames?

2023-10-24 Thread Ki Rill via Digitalmars-d-learn
On Tuesday, 24 October 2023 at 05:03:51 UTC, Imperatorn wrote: On Tuesday, 24 October 2023 at 04:38:58 UTC, Ki Rill wrote: I know how to change the current AppFrame: ```D window.mainWidget = myFrame; ``` But how do I exit this frame? I press the button, change to new frame, do the work, and no

Re: C to D: please help translate this weird macro

2023-09-23 Thread Ki Rill via Digitalmars-d-learn
On Wednesday, 20 September 2023 at 13:53:08 UTC, Ki Rill wrote: Here is the macro: ```C #define NK_CONTAINER_OF(ptr,type,member)\ (type*)((void*)((char*)(1 ? (ptr): &((type*)0)->member) - NK_OFFSETOF(type, member))) ``` I'm trying to translate the Nuklear GUI library to D [here](https://

Re: C to D: please help translate this weird macro

2023-09-22 Thread Ki Rill via Digitalmars-d-learn
On Thursday, 21 September 2023 at 16:50:51 UTC, Imperatorn wrote: On Wednesday, 20 September 2023 at 13:53:08 UTC, Ki Rill wrote: Here is the macro: ```C #define NK_CONTAINER_OF(ptr,type,member)\ (type*)((void*)((char*)(1 ? (ptr): &((type*)0)->member) - NK_OFFSETOF(type, member))) ``` I'

Re: C to D: please help translate this weird macro

2023-09-22 Thread Ki Rill via Digitalmars-d-learn
On Thursday, 21 September 2023 at 16:28:25 UTC, Nick Treleaven wrote: The 1st argument of `getMember` can just be T, like the original macro. The 2nd argument needs to be a compile-time string. Also the `char*` cast needs to apply to `ptr` before subtracting the offset AFAICS. So reordering

Re: C to D: please help translate this weird macro

2023-09-20 Thread Ki Rill via Digitalmars-d-learn
On Thursday, 21 September 2023 at 02:23:32 UTC, Ki Rill wrote: wrote: [...] Translated it to this eventually: ```D auto nk_container_of(P, T)(P ptr, T type, const(char)* member) { return cast(T*)(cast(void*)(cast(char*) (ptr - __traits(getMember, type, member).offsetof))); } ```

Re: C to D: please help translate this weird macro

2023-09-20 Thread Ki Rill via Digitalmars-d-learn
On Wednesday, 20 September 2023 at 17:14:41 UTC, Dejan Lekic wrote: [...] NK_CONTAINER_OF should probably be translated to: `cast(T*)((cast(void*)ptr - __traits(getMember, T, member).offsetof))` PS. I did not invent this. My original idea was far worse than this. - It was suggested on IRC b

Re: C to D: please help translate this weird macro

2023-09-20 Thread Ki Rill via Digitalmars-d-learn
On Wednesday, 20 September 2023 at 13:53:08 UTC, Ki Rill wrote: Here is the macro: ```C #define NK_CONTAINER_OF(ptr,type,member)\ (type*)((void*)((char*)(1 ? (ptr): &((type*)0)->member) - NK_OFFSETOF(type, member))) ``` I'm trying to translate the Nuklear GUI library to D [here](https://

C to D: please help translate this weird macro

2023-09-20 Thread Ki Rill via Digitalmars-d-learn
Here is the macro: ```C #define NK_CONTAINER_OF(ptr,type,member)\ (type*)((void*)((char*)(1 ? (ptr): &((type*)0)->member) - NK_OFFSETOF(type, member))) ``` I'm trying to translate the Nuklear GUI library to D [here](https://github.com/rillki/nuklear-d/tree/nuklear-d-translation).

Re: Which function returns a pair after division ? (integer,frac)

2023-09-18 Thread Ki Rill via Digitalmars-d-learn
On Tuesday, 19 September 2023 at 03:44:18 UTC, Vitaliy Fadeev wrote: What D function or D operator does this? ```asm IDIV EAX, r/m32 ``` ``` IDIV 5, 2 EAX = 2 EDX = 1 ``` and returns (2,1) at once? You can either use function `out` parameters with return value or `tuples`: ```D import st

Re: Mir-algorithm tutorial?

2023-08-18 Thread Ki Rill via Digitalmars-d-learn
On Friday, 18 August 2023 at 09:32:31 UTC, Ferhat Kurtulmuş wrote: I believe the most recent docs for mir-algorithm is here http://mir-algorithm.libmir.org/ Thanks. Yes, that's the only thing. However, it's not a good starting point for someone who just wants to get to know the library and pl

Re: Mir-algorithm tutorial?

2023-08-18 Thread Ki Rill via Digitalmars-d-learn
On Friday, 18 August 2023 at 07:57:05 UTC, Ki Rill wrote: On Friday, 18 August 2023 at 07:54:04 UTC, Ki Rill wrote: Is there an up-to-date tutorial? It's just painful that I cannot find anything helpful on this topic. The official mir-algorithm GitHub repo links to articles with old code that

Re: Mir-algorithm tutorial?

2023-08-18 Thread Ki Rill via Digitalmars-d-learn
On Friday, 18 August 2023 at 07:54:04 UTC, Ki Rill wrote: Is there an up-to-date tutorial? It's just painful that I cannot find anything helpful on this topic. The official mir-algorithm GitHub repo links to articles with old code that won't build if I copy-paste it. I'm left hunting down the

Mir-algorithm tutorial?

2023-08-18 Thread Ki Rill via Digitalmars-d-learn
Is there an up-to-date tutorial? It's just painful that I cannot find anything helpful on this topic. The official mir-algorithm GitHub repo links to articles with old code that won't build if I copy-paste it. I'm left hunting down the changes and guessing how things should really work.

Re: On assigning const to immutable

2023-07-13 Thread Ki Rill via Digitalmars-d-learn
On Thursday, 13 July 2023 at 11:55:17 UTC, Ki Rill wrote: Why does the first example `class A` work, but the second one with `class B` does not? ```D class A { immutable int a; this(in int a) { this.a = a; } } class B { immutable int[] b; this(in int[] b) { t

On assigning const to immutable

2023-07-13 Thread Ki Rill via Digitalmars-d-learn
Why does the first example `class A` work, but the second one with `class B` does not? ```D class A { immutable int a; this(in int a) { this.a = a; } } class B { immutable int[] b; this(in int[] b) { this.b = b; } } void main() { auto a = new A(1)

Re: Designated initializers to function argument

2023-07-11 Thread Ki Rill via Digitalmars-d-learn
On Tuesday, 11 July 2023 at 15:16:54 UTC, Ki Rill wrote: ```D // or this apply(Appearance(color: BLACK, strokeWidth: 4)); // other fields are default initialized: strokeOpacity, fillOpacity, etc... ``` Ok, this works with DMD v2.103, but does not work with an older version (I had ldc2 ins

Designated initializers to function argument

2023-07-11 Thread Ki Rill via Digitalmars-d-learn
In C I can do the following: ```C void apply(struct Appearance a) {...} // usage apply((struct Appearance) { .color = BLACK, .strokeWidth = 4 }); ``` Can I do the same in D without creating a struct variable separately? ```D void apply(Appearance a) {...} // currently accepts Appearan

Re: How to setup dub project for contributing to a dub package?

2023-06-23 Thread Ki Rill via Digitalmars-d-learn
On Friday, 23 June 2023 at 15:52:44 UTC, Richard (Rikki) Andrew Cattermole wrote: First things first, dcv is added to the dub-registry, so use this. https://code.dlang.org/packages/dcv ```json "dependencies": { "dcv": "~>0.3.0" } ``` For ffmpeg the binding tells you what to add for se

How to setup dub project for contributing to a dub package?

2023-06-23 Thread Ki Rill via Digitalmars-d-learn
Recently, I tried to set up `dcv` with `dub` to improve a few things in the library, but I faced some strange issues. When doing `dub add dcv`, it works fine. But when I try to add a local dcv project folder, or a repository, it fails to link the necessary package libraries. Seems like it's on

Re: How do I generate `setX` methods for all private mutable variables in a class?

2023-06-06 Thread Ki Rill via Digitalmars-d-learn
On Monday, 5 June 2023 at 18:54:30 UTC, cc wrote: [...] Is there a way to check for mutability as well? I have both immutable and mutable fields. I would like to generate setters for mutable fields only.

Re: How do I generate `setX` methods for all private mutable variables in a class?

2023-06-05 Thread Ki Rill via Digitalmars-d-learn
On Monday, 5 June 2023 at 18:54:30 UTC, cc wrote: On Monday, 5 June 2023 at 13:57:20 UTC, Ki Rill wrote: How do I generate `setX` methods for all private mutable variables in my class? Do I need to use `__traits`? ```d mixin template GenerateSetters() { static foreach (idx, field; typeof(this

How do I generate `setX` methods for all private mutable variables in a class?

2023-06-05 Thread Ki Rill via Digitalmars-d-learn
How do I generate `setX` methods for all private mutable variables in my class? Do I need to use `__traits`? I need this for my [tiny-svg](https://github.com/rillki/tiny-svg) project to generate `setX` methods for all Shapes. Example: ```D class Rectangle { private immutable ...; priv

Re: How to setup D with SFML? (using bindbc-sfml)

2023-04-14 Thread Ki Rill via Digitalmars-d-learn
On Friday, 14 April 2023 at 02:33:18 UTC, Salih Dincer wrote: On Friday, 14 April 2023 at 00:28:53 UTC, Ki Rill wrote: ``` LINK : fatal error LNK1104: cannot open file 'libucrt.lib' Error: linker exited with status 1104 ``` Why does it require this library and where can I find it? Since this

Re: How to setup D with SFML? (using bindbc-sfml)

2023-04-13 Thread Ki Rill via Digitalmars-d-learn
On Wednesday, 12 April 2023 at 10:05:14 UTC, Salih Dincer wrote: On Tuesday, 11 April 2023 at 10:24:09 UTC, Ki Rill wrote: If you wanted static I would add and run libraries easy, like this: ```Json "libs": [ "csfml-audio", "csfml-graphics" ],

Re: How to setup D with SFML? (using bindbc-sfml)

2023-04-11 Thread Ki Rill via Digitalmars-d-learn
On Tuesday, 11 April 2023 at 11:55:50 UTC, Richard (Rikki) Andrew Cattermole wrote: I have to ask this since nothing else has worked and the dll's on the site don't depend on a MSVC dll: What are you compiling your program as? 32bit/64bit x86? ARM? Which DLL's are you downloading? 32bit, 64bit

Re: How to setup D with SFML? (using bindbc-sfml)

2023-04-11 Thread Ki Rill via Digitalmars-d-learn
On Sunday, 9 April 2023 at 14:20:30 UTC, Mike Parker wrote: I've tried your project out two ways, one that succeeds and one that fails. I'm guessing you've put your 'libs' directory is 'bin/libs'. Am I right? If so, then the following should help you. Well, `bin/` and `libs/` are in the same

Re: How to setup D with SFML? (using bindbc-sfml)

2023-04-09 Thread Ki Rill via Digitalmars-d-learn
On Saturday, 8 April 2023 at 23:40:32 UTC, Mike Parker wrote: On Saturday, 8 April 2023 at 11:31:40 UTC, Ki Rill wrote: How do I set up a D and SFML project using the `bindbc-sfml` package? I tried following the instructions, it builds successfully, but fails to load the SFML library at runti

How to setup D with SFML? (using bindbc-sfml)

2023-04-08 Thread Ki Rill via Digitalmars-d-learn
How do I set up a D and SFML project using the `bindbc-sfml` package? I tried following the instructions, it builds successfully, but fails to load the SFML library at runtime. In particular, `loadSFML, loadSFMLGraphics, loadSFMLXXX` fails. Here is [link](https://github.com/rillki/d-sfml-pro

Re: Failed to archive JPEG (ArchiveMember): Invalid UTF-8 sequence (at index 1)

2023-01-13 Thread Ki Rill via Digitalmars-d-learn
On Saturday, 14 January 2023 at 01:13:33 UTC, Adam D Ruppe wrote: On Saturday, 14 January 2023 at 01:08:25 UTC, Ki Rill wrote: a JPEG image. member.expandedData(file.readText().dup().representation()); A jpeg image is not a text file. Read it with `std.file.read()` instead of `readText`

Failed to archive JPEG (ArchiveMember): Invalid UTF-8 sequence (at index 1)

2023-01-13 Thread Ki Rill via Digitalmars-d-learn
Please, help me solve the annoying error above. I've been refactoring and rewriting code for my archive utility called [zippo](https://github.com/rillki/zippo) and I face this error when it tries to archive a JPEG image. I tracked it down to the following function that helps me add a new memb

Re: DUB: How to link an external library on Windows 10?

2021-08-27 Thread Ki Rill via Digitalmars-d-learn
On Friday, 27 August 2021 at 15:24:14 UTC, Steven Schveighoffer wrote: I suspect your MSVC installation is bad, or there are some other switches causing problems. -Steve Hmm... well, I will use the default setup and think about it later. I mostly use Linux, Windows realm is an uncharted te

Re: DUB: How to link an external library on Windows 10?

2021-08-27 Thread Ki Rill via Digitalmars-d-learn
On Friday, 27 August 2021 at 14:52:15 UTC, Mike Parker wrote: On Friday, 27 August 2021 at 14:46:56 UTC, Ki Rill wrote: On Friday, 27 August 2021 at 13:54:18 UTC, Steven Schveighoffer wrote: [...] How do I tell DUB where to look for `raylibdll.lib` and `raylib.dll`? Via `lflags` section? Wha

Re: DUB: How to link an external library on Windows 10?

2021-08-27 Thread Ki Rill via Digitalmars-d-learn
On Friday, 27 August 2021 at 13:54:18 UTC, Steven Schveighoffer wrote: [...] How do I tell DUB where to look for `raylibdll.lib` and `raylib.dll`? Via `lflags` section? What if I put them in a different folder instead of the project's directory?

Re: DUB: How to link an external library on Windows 10?

2021-08-27 Thread Ki Rill via Digitalmars-d-learn
On Friday, 27 August 2021 at 13:54:25 UTC, Mike Parker wrote: But assuming you are on a 64-bit system, the DMD will use Visual Studio's linker if you have it installed. If you don't, it will use the lld linker it ships with. Either way, you need to raylib to be compiled with he same version of

Re: DUB: How to link an external library on Windows 10?

2021-08-27 Thread Ki Rill via Digitalmars-d-learn
On Friday, 27 August 2021 at 13:54:18 UTC, Steven Schveighoffer wrote: In the end, I got it to build and run, but I'd highly recommend just linking against the `raylibdll.lib` and using the dll. -Steve Steve, thank you! I got it working with `raylibdll.lib`! SOLUTION: 1. `dub init` 2. `dub

Re: DUB: How to link an external library on Windows 10?

2021-08-27 Thread Ki Rill via Digitalmars-d-learn
On Friday, 27 August 2021 at 13:33:25 UTC, Mike Parker wrote: On Friday, 27 August 2021 at 13:21:04 UTC, Ki Rill wrote: I have a Raylib project on Windows using DUB. I've added raylib-d via `dub add`. But what I can't figure out is how to tell DUB to link against raylib library. I have the fo

DUB: How to link an external library on Windows 10?

2021-08-27 Thread Ki Rill via Digitalmars-d-learn
I have a Raylib project on Windows using DUB. I've added raylib-d via `dub add`. But what I can't figure out is how to tell DUB to link against raylib library. I have the following project structure: ``` -> source ---> app.d -> libraylib.a -> raylib.dll -> etc... ``` I'd like to use either .a