Re: Forcing my module to be initialized first

2023-10-16 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
Okay, after looking at gtkd, I don't think this can be solved with module constructors or swapping out to lazy initialization. One way that might work however is to use a crt_constructor as that runs before the D stuff. However it would now hard code your program to your system. Over all my su

protobuf error: Tag value out of range

2023-10-16 Thread zoujiaqing via Digitalmars-d-learn
code: ```d auto req = new ApplyContact(); data.fromProtobuf!ApplyContact(req); ``` protobuf: ```d class ApplyContact { @Proto(1) string fromId = protoDefaultValue!string; @Proto(2) string toId = protoDefaultValue!string; @Proto(3) string message = protoDefaultValue!string; @Proto

Re: protobuf error: Tag value out of range

2023-10-16 Thread zoujiaqing via Digitalmars-d-learn
I was using a different version of dmd. Problem solved. thank you

Re: dlang.org/spec/function.html#pure-functions example

2023-10-16 Thread Paul via Digitalmars-d-learn
On Thursday, 12 October 2023 at 21:20:44 UTC, Jonathan M Davis wrote: Thanks Jonathan

Re: dlang.org/spec/function.html#pure-functions example

2023-10-16 Thread Paul via Digitalmars-d-learn
On Thursday, 12 October 2023 at 21:20:44 UTC, Jonathan M Davis wrote: look like? Types can have static members. Basically what it comes down to is that outside of immutable data, pure functions only have access to their arguments and to what they can access via their arguments (be it by getti

strange link error: _My_struct__xtoHashFNbNeKxSQBlQBoQBiZm _My_struct__xopEqualsMxFKxSQBlQBoQBiZb

2023-10-16 Thread mw via Digitalmars-d-learn
Hi, I just encountered a strange link error: I have a `struct` type `My_struct`, the program compiles fine, but at link time, it errors out: undefined reference to _My_struct__xtoHashFNbNeKxSQBlQBoQBiZm undefined reference to _My_struct__xopEqualsMxFKxSQBlQBoQBiZb looks like it treats My_str

Re: Forcing my module to be initialized first

2023-10-16 Thread dan via Digitalmars-d-learn
On Monday, 16 October 2023 at 10:23:54 UTC, Richard (Rikki) Andrew Cattermole wrote: Okay, after looking at gtkd, I don't think this can be solved with module constructors or swapping out to lazy initialization. One way that might work however is to use a crt_constructor as that runs before th

Setting GTK_BASEPATH for gtkd

2023-10-16 Thread bachmeier via Digitalmars-d-learn
On Monday, 16 October 2023 at 18:28:52 UTC, dan wrote: (Now, i still think that when module initialization order is not forced, it should be something a programmer or systems integrator can choose, but i don't want to be too greedy.) Thanks again for your help!! dan I changed the subject l

Re: strange link error: _My_struct__xtoHashFNbNeKxSQBlQBoQBiZm _My_struct__xopEqualsMxFKxSQBlQBoQBiZb

2023-10-16 Thread Imperatorn via Digitalmars-d-learn
On Monday, 16 October 2023 at 18:20:27 UTC, mw wrote: Hi, I just encountered a strange link error: I have a `struct` type `My_struct`, the program compiles fine, but at link time, it errors out: undefined reference to _My_struct__xtoHashFNbNeKxSQBlQBoQBiZm undefined reference to _My_struct__

Re: strange link error: _My_struct__xtoHashFNbNeKxSQBlQBoQBiZm _My_struct__xopEqualsMxFKxSQBlQBoQBiZb

2023-10-16 Thread ryuukk_ via Digitalmars-d-learn
On Monday, 16 October 2023 at 19:36:07 UTC, Imperatorn wrote: On Monday, 16 October 2023 at 18:20:27 UTC, mw wrote: Hi, I just encountered a strange link error: I have a `struct` type `My_struct`, the program compiles fine, but at link time, it errors out: undefined reference to _My_struct_

Re: Setting GTK_BASEPATH for gtkd

2023-10-16 Thread dan via Digitalmars-d-learn
On Monday, 16 October 2023 at 18:57:45 UTC, bachmeier wrote: On Monday, 16 October 2023 at 18:28:52 UTC, dan wrote: (Now, i still think that when module initialization order is not forced, it should be something a programmer or systems integrator can choose, but i don't want to be too greedy.)

Re: strange link error: _My_struct__xtoHashFNbNeKxSQBlQBoQBiZm _My_struct__xopEqualsMxFKxSQBlQBoQBiZb

2023-10-16 Thread Imperatorn via Digitalmars-d-learn
On Monday, 16 October 2023 at 20:06:02 UTC, ryuukk_ wrote: On Monday, 16 October 2023 at 19:36:07 UTC, Imperatorn wrote: On Monday, 16 October 2023 at 18:20:27 UTC, mw wrote: [...] Show your code here on in Discord https://discord.gg/wKTvGNpc No, show your code here on the forum, don't nee

Re: strange link error: _My_struct__xtoHashFNbNeKxSQBlQBoQBiZm _My_struct__xopEqualsMxFKxSQBlQBoQBiZb

2023-10-16 Thread mw via Digitalmars-d-learn
It's very hard to isolate the problem. I have comment out that piece part of code for now (non-essential part of my program): comment out where the struct is used, not the struct definition. Anyway, I will try some time later.

Re: strange link error: _My_struct__xtoHashFNbNeKxSQBlQBoQBiZm _My_struct__xopEqualsMxFKxSQBlQBoQBiZb

2023-10-16 Thread mw via Digitalmars-d-learn
On Monday, 16 October 2023 at 21:20:39 UTC, mw wrote: It's very hard to isolate the problem. I have comment out that piece part of code for now (non-essential part of my program): comment out where the struct is used, not the struct definition. Anyway, I will try some time later. BTW, the st

Re: strange link error: _My_struct__xtoHashFNbNeKxSQBlQBoQBiZm _My_struct__xopEqualsMxFKxSQBlQBoQBiZb

2023-10-16 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
xtoHash and xopEquals are generated by the compiler automatically. Curiously those two symbol names are not demangling. Given this, I suspect the best thing to do is file a bug report with ldc with the code that generated the linker error.

Re: strange link error: _My_struct__xtoHashFNbNeKxSQBlQBoQBiZm _My_struct__xopEqualsMxFKxSQBlQBoQBiZb

2023-10-16 Thread mw via Digitalmars-d-learn
On Tuesday, 17 October 2023 at 00:44:17 UTC, Richard (Rikki) Andrew Cattermole wrote: xtoHash and xopEquals are generated by the compiler automatically. Curiously those two symbol names are not demangling. Given this, I suspect the best thing to do is file a bug report with ldc with the code

Re: strange link error: _My_struct__xtoHashFNbNeKxSQBlQBoQBiZm _My_struct__xopEqualsMxFKxSQBlQBoQBiZb

2023-10-16 Thread mw via Digitalmars-d-learn
On Tuesday, 17 October 2023 at 00:44:17 UTC, Richard (Rikki) Andrew Cattermole wrote: xtoHash and xopEquals are generated by the compiler automatically. These two are for `class`, but shouldn't be generated for `struct`, right?

Re: strange link error: _My_struct__xtoHashFNbNeKxSQBlQBoQBiZm _My_struct__xopEqualsMxFKxSQBlQBoQBiZb

2023-10-16 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
They are for structs as well.

Re: strange link error: _My_struct__xtoHashFNbNeKxSQBlQBoQBiZm _My_struct__xopEqualsMxFKxSQBlQBoQBiZb

2023-10-16 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 17/10/2023 1:58 PM, mw wrote: Oh the <_My_struct> part is my simplification, it is mangled as something like : _D6..<_My_struct>..__xtoHashFNbNeKxSQBlQBoQBiZm When dealing with linker errors, please do not simplify, it can make problems unsolvable.

Re: strange link error: _My_struct__xtoHashFNbNeKxSQBlQBoQBiZm _My_struct__xopEqualsMxFKxSQBlQBoQBiZb

2023-10-16 Thread mw via Digitalmars-d-learn
On Tuesday, 17 October 2023 at 01:11:13 UTC, Richard (Rikki) Andrew Cattermole wrote: They are for structs as well. Ah?! I use quite a few struts, but I never have provided such two methods.

Re: strange link error: _My_struct__xtoHashFNbNeKxSQBlQBoQBiZm _My_struct__xopEqualsMxFKxSQBlQBoQBiZb

2023-10-16 Thread mw via Digitalmars-d-learn
On Tuesday, 17 October 2023 at 01:14:04 UTC, Richard (Rikki) Andrew Cattermole wrote: On 17/10/2023 1:58 PM, mw wrote: Oh the <_My_struct> part is my simplification, it is mangled as something like : _D6..<_My_struct>..__xtoHashFNbNeKxSQBlQBoQBiZm When dealing with linker errors, please do no

Re: strange link error: _My_struct__xtoHashFNbNeKxSQBlQBoQBiZm _My_struct__xopEqualsMxFKxSQBlQBoQBiZb

2023-10-16 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 17/10/2023 2:15 PM, mw wrote: On Tuesday, 17 October 2023 at 01:11:13 UTC, Richard (Rikki) Andrew Cattermole wrote: They are for structs as well. Ah?! I use quite a few struts, but I never have provided such two methods. Indeed, they are generated by the compiler, not user provided. They

Re: strange link error: _My_struct__xtoHashFNbNeKxSQBlQBoQBiZm _My_struct__xopEqualsMxFKxSQBlQBoQBiZb

2023-10-16 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 17/10/2023 2:17 PM, mw wrote: It's just my own module and type name, nothing special or interesting. Doesn't matter. Because I now can't demangle it and figure out what its trying to find without doing that by hand. Every character in a symbol name is significant, you can't remove some of

Re: strange link error: _My_struct__xtoHashFNbNeKxSQBlQBoQBiZm _My_struct__xopEqualsMxFKxSQBlQBoQBiZb

2023-10-16 Thread mw via Digitalmars-d-learn
On Tuesday, 17 October 2023 at 01:54:12 UTC, Richard (Rikki) Andrew Cattermole wrote: On 17/10/2023 2:15 PM, mw wrote: On Tuesday, 17 October 2023 at 01:11:13 UTC, Richard (Rikki) Andrew Cattermole wrote: They are for structs as well. Ah?! I use quite a few struts, but I never have provided s

Re: strange link error: _My_struct__xtoHashFNbNeKxSQBlQBoQBiZm _My_struct__xopEqualsMxFKxSQBlQBoQBiZb

2023-10-16 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 17/10/2023 4:18 PM, mw wrote: Is string basic types? as I showed one earlier Foo {one string and two ints}, my other struct only has double and long, it also has the same link errors about toHash and opEquals. string is not a basic type, its a slice, which means pointer.

std.format with named args

2023-10-16 Thread Vitaliy Fadeev via Digitalmars-d-learn
Hi all! I want readable mixin. I want pass variable to string. I want string with named args. Like this: ```D enum JMP_ADDR_R = "RAX"; mixin( format!"asm { jmp [JMP_ADDR_R]; }"( JMP_ADDR_R ));// IT NOT WORK ``` Not this: ```D enum JMP_ADDR_R = "RAX"; mixin( form