Re: static init c struct with array filed

2022-03-16 Thread Adam Ruppe via Digitalmars-d-learn
On Thursday, 17 March 2022 at 00:16:39 UTC, Mike Parker wrote: On Wednesday, 16 March 2022 at 07:27:06 UTC, test wrote: ```c struct Test { int32_t a; } struct Test2 { int32_t a; Test arr[]; } ``` I need static const init Test2, then pass it to c library late(third library, can not

Re: static init c struct with array filed

2022-03-16 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 16 March 2022 at 07:27:06 UTC, test wrote: ```c struct Test { int32_t a; } struct Test2 { int32_t a; Test arr[]; } ``` I need static const init Test2, then pass it to c library late(third library, can not change the type def). Any time you see a '[]' in C, the

Re: Make shared static this() encoding table compilable

2022-03-16 Thread Salih Dincer via Digitalmars-d-learn
On Wednesday, 16 March 2022 at 18:40:35 UTC, zhad3 wrote: On Tuesday, 15 March 2022 at 03:01:05 UTC, Salih Dincer wrote: OMG, I gasp at my computer screen and waited for minutes. :) When you edit the code at the back-end level, you can use system resources in the best way. I think you should

Re: Make shared static this() encoding table compilable

2022-03-16 Thread zhad3 via Digitalmars-d-learn
On Tuesday, 15 March 2022 at 03:01:05 UTC, Salih Dincer wrote: OMG, I gasp at my computer screen and waited for minutes. :) When you edit the code at the back-end level, you can use system resources in the best way. I think you should start with

Re: Make shared static this() encoding table compilable

2022-03-16 Thread zhad3 via Digitalmars-d-learn
On Monday, 14 March 2022 at 22:20:42 UTC, rikki cattermole wrote: The recommended solution by Unicode is to use Trie tables for Look Up Tables (LUTs). https://en.wikipedia.org/wiki/Trie You can generate these as read only global arrays and are very fast for this. Thank your for this

Re: Make shared static this() encoding table compilable

2022-03-16 Thread zhad3 via Digitalmars-d-learn
On Monday, 14 March 2022 at 19:05:41 UTC, Ali Çehreli wrote: Yes, better but not much: 37 seconds vs. 50+ seconds on my system. Even though I am pretty sure the OP has access to the keys and the values separately, if it helps, I used the following code to separate the keys and values:

Re: Make shared static this() encoding table compilable

2022-03-16 Thread zhad3 via Digitalmars-d-learn
On Monday, 14 March 2022 at 10:23:18 UTC, bauss wrote: I think it's a memory issue and it's unlikely to be solved. I saw a similar issue a while ago where it worked with everything but DMD. Someone can correct me but if I remember correctly it's because DMD issues instructions for each

Re: Make shared static this() encoding table compilable

2022-03-16 Thread zhad3 via Digitalmars-d-learn
On Monday, 14 March 2022 at 10:07:52 UTC, Basile B. wrote: That's a compiler bug of type "ICE", the compiler crashes. Try reducing to a simple module that does not use phobos and report to bugzilla. Thank you and sorry for the late reply, I have been quite busy. You can test this already with

Re: static init c struct with array filed

2022-03-16 Thread Ali Çehreli via Digitalmars-d-learn
On 3/16/22 10:03, user1234 wrote: > On Wednesday, 16 March 2022 at 14:42:02 UTC, Era Scarecrow wrote: >> On Wednesday, 16 March 2022 at 11:27:20 UTC, user1234 wrote: >>> assuming the c library takes by reference >> >> My experience all arrays are effectively just pointers > > I meant the

Re: static init c struct with array filed

2022-03-16 Thread user1234 via Digitalmars-d-learn
On Wednesday, 16 March 2022 at 14:42:02 UTC, Era Scarecrow wrote: On Wednesday, 16 March 2022 at 11:27:20 UTC, user1234 wrote: assuming the c library takes by reference My experience all arrays are effectively just pointers I meant the function that takes the Test2 as parameter, but to be

Re: static init c struct with array filed

2022-03-16 Thread Era Scarecrow via Digitalmars-d-learn
On Wednesday, 16 March 2022 at 11:27:20 UTC, user1234 wrote: assuming the c library takes by reference My experience all arrays are effectively just pointers, and the brackets/length is only really applicable to stack allocated fixed length allocations. In my own C projects i always used

Re: static init c struct with array filed

2022-03-16 Thread user1234 via Digitalmars-d-learn
On Wednesday, 16 March 2022 at 07:27:06 UTC, test wrote: ```c struct Test { int32_t a; } struct Test2 { int32_t a; Test arr[]; } ``` I need static const init Test2, then pass it to c library late(third library, can not change the type def). I am not sure how to do it in D.

static init c struct with array filed

2022-03-16 Thread test via Digitalmars-d-learn
```c struct Test { int32_t a; } struct Test2 { int32_t a; Test arr[]; } ``` I need static const init Test2, then pass it to c library late(third library, can not change the type def). I am not sure how to do it in D.