Error: cannot use non-constant CTFE pointer in an initializer `cast(immutable(char)*)TEST`

2022-06-11 Thread test123 via Digitalmars-d-learn
how to work this around. ```d __gshared const TEST = import(`onlineapp.d`); extern(C) void main(){ __gshared bin_ptr = TEST.ptr; } ``` ```sh dmd2 -betterC -J. onlineapp.d onlineapp.d(3): Error: cannot use non-constant CTFE pointer in an initializer `cast(immutable(char)*)TEST` ```

get debug information for Deprecation warning

2022-06-22 Thread test123 via Digitalmars-d-learn
When I get Deprecation warning from template, I can not find the root cause of the problem. ```sh Deprecation: argument `_param_1` for format specification `"%d"` must be `int`, not `ulong` ``` Is there a options to turn the Deprecation warning into assert error, so I can know the templa

Reading parquet files from D

2022-06-23 Thread test123 via Digitalmars-d-learn
https://forum.dlang.org/post/mkgelbxeqvhbdsukg...@forum.dlang.org On Monday, 14 October 2019 at 20:13:43 UTC, jmh530 wrote: On Monday, 14 October 2019 at 19:27:04 UTC, Andre Pany wrote: [snip] I found this tool https://github.com/gtkd-developers/gir-to-d from Mike Wey which translates GObject

please help me to reverse a function call order

2022-07-23 Thread Test123 via Digitalmars-d-learn
I has this function, it print all possible combinations. ```d void doRepetition(const int n, const int m){ // combination total number is m, element is repeatable. assert(n >= 1 && n < 10); assert(m >= 1 && m < 10); enum N = 10; ubyte[10] a; void inc(int index, int r, int

Re: please help me to reverse a function call order

2022-07-23 Thread Test123 via Digitalmars-d-learn
On Saturday, 23 July 2022 at 19:50:51 UTC, Test123 wrote: I has this function, it print all possible combinations. ```d void doRepetition(const int n, const int m){ // combination total number is m, element is repeatable. assert(n >= 1 && n < 10); assert(m >= 1 && m < 10); enum

Re: please help me to reverse a function call order

2022-07-23 Thread Test123 via Digitalmars-d-learn
On Saturday, 23 July 2022 at 20:00:06 UTC, rikki cattermole wrote: A bit more d-ified and uses foreach + foreach_reverse without allocating an array. [...] Thanks for the quick reply. I also get your results, it is not correct because the secends number is not matched. Not I look at you

Re: please help me to reverse a function call order

2022-07-23 Thread Test123 via Digitalmars-d-learn
On Saturday, 23 July 2022 at 20:00:06 UTC, rikki cattermole wrote: A bit more d-ified and uses foreach + foreach_reverse without allocating an array. [...] Your give the correct code, but wrong Output. Thanks again for the help.

Re: please help me to reverse a function call order

2022-07-24 Thread Test123 via Digitalmars-d-learn
On Saturday, 23 July 2022 at 23:14:03 UTC, Salih Dincer wrote: On Saturday, 23 July 2022 at 22:50:55 UTC, Salih Dincer wrote: [...] I guess my code didn't list all possibilities either. Moreover, the m and n parameters will be swapped: [...] **PS.** * marked from version(c) in the above

Re: please help me to reverse a function call order

2022-07-24 Thread test123 via Digitalmars-d-learn
On Sunday, 24 July 2022 at 15:49:51 UTC, Salih Dincer wrote: On Sunday, 24 July 2022 at 15:11:45 UTC, Salih Dincer wrote: ...But you know this classic recurisive function: The `permut()` function works with many types, for example `char`. Look at probability 40: 😀 ```d void main() { int t

Re: please help me to reverse a function call order

2022-07-26 Thread Test123 via Digitalmars-d-learn
On Monday, 25 July 2022 at 21:43:37 UTC, Salih Dincer wrote: On Monday, 25 July 2022 at 04:23:16 UTC, test123 wrote: not match by: 1) the element is not repeat 2) the element is position related I got it now. So what good are such repetitive probabilities? Thanks... SDB@79 just try a stu

never seed this kind problem with localtime_r

2022-08-01 Thread test123 via Digitalmars-d-learn
I have an app, when it start localtime_r return correct value. after some time, localtime_r return Thu Jan 1 0:00:00 1970 for same input value. please help me give any suggestion how to handle this problem.

need help to translate C into D

2022-09-12 Thread test123 via Digitalmars-d-learn
I can not use importC, I need it to be work in D code. ```d typedef struct { uint32_t mask_limit; // Limit enum value that can be tested with mask. uint32_t value_count; // Number of values after the bitfield. uint32_t data[]; // Bitmask + enumerated values follow. } upb_MiniTab

Re: need help to translate C into D

2022-09-13 Thread test123 via Digitalmars-d-learn
On Tuesday, 13 September 2022 at 07:31:50 UTC, Marvin wrote: On Tuesday, 13 September 2022 at 06:04:49 UTC, test123 wrote: I can not use importC, I need it to be work in D code. ```d typedef struct { uint32_t mask_limit; // Limit enum value that can be tested with mask. uint32_t value_c

Re: need help to translate C into D

2022-09-13 Thread test123 via Digitalmars-d-learn
On Tuesday, 13 September 2022 at 09:57:38 UTC, Dennis wrote: On Tuesday, 13 September 2022 at 09:43:46 UTC, test123 wrote: This will not work since the C have no array like D. You can use a 0-size static array: ```D struct mystruct { uint32_t mask_limit; // Limit enum value that can be test

Re: need help to translate C into D

2022-09-13 Thread test123 via Digitalmars-d-learn
On Tuesday, 13 September 2022 at 10:45:03 UTC, test123 wrote: upb_MiniTable_Enum array ? 2 type error I think it cloud be compiler bugs. 1): `expression `&validate_KnownRegex_enum_init_type(64u, 2u, [7u, 0u], ).header` is not a constant` ```d union validate_KnownRegex_enum_init_type {

Re: need help to translate C into D

2022-09-13 Thread test123 via Digitalmars-d-learn
On Tuesday, 13 September 2022 at 10:59:36 UTC, Dennis wrote: On Tuesday, 13 September 2022 at 10:45:03 UTC, test123 wrote: Is there a way to init the __gshared fixed length upb_MiniTable_Enum array ? I don't think so. You could leave your array typed as `validate_KnownRegex_enum_init_type` an

Re: need help to translate C into D

2022-09-13 Thread test123 via Digitalmars-d-learn
On Tuesday, 13 September 2022 at 10:59:36 UTC, Dennis wrote: On Tuesday, 13 September 2022 at 10:45:03 UTC, test123 wrote: Is there a way to init the __gshared fixed length upb_MiniTable_Enum array ? I don't think so. You could leave your array typed as `validate_KnownRegex_enum_init_type` an

Re: need help to translate C into D

2022-09-13 Thread test123 via Digitalmars-d-learn
On Tuesday, 13 September 2022 at 10:59:36 UTC, Dennis wrote: On Tuesday, 13 September 2022 at 10:45:03 UTC, test123 wrote: Is there a way to init the __gshared fixed length upb_MiniTable_Enum array ? I don't think so. You could leave your array typed as `validate_KnownRegex_enum_init_type` an

can not take const struct member address at CTFE , is this a bug?

2022-09-13 Thread test123 via Digitalmars-d-learn
```d struct c { uint a, b;} __gshared const c d = { 3, 4}; __gshared const e = &d.a; ``` ./test.d(4): Error: expression `&c(3u, 4u).a` is not a constant I need this to work around C struct array member like this: ```c struct c { uint32_t a, b; uint32_t[] arr; } ``` If I

Re: need help to translate C into D

2022-09-13 Thread test123 via Digitalmars-d-learn
On Tuesday, 13 September 2022 at 11:29:12 UTC, Dennis wrote: On Tuesday, 13 September 2022 at 11:03:30 UTC, test123 wrote: and upb_MiniTable_Enum can include a lot diff types. (for example mixed diff size upb_MiniTable_Enum) I think you'll need a `void*` array then, since pointers to differen

Re: can not take const struct member address at CTFE , is this a bug?

2022-09-13 Thread test123 via Digitalmars-d-learn
On Wednesday, 14 September 2022 at 00:40:38 UTC, Ruby The Roobster wrote: The addresses of items stored in memory are by definition not constant. This isn't a bug. If so why this can work ? ```d struct c { uint a, b;} __gshared const c d = { 3, 4}; __gshared const e = & d; ``` the `e` can ge

Re: need help to translate C into D

2022-09-13 Thread test123 via Digitalmars-d-learn
On Tuesday, 13 September 2022 at 23:34:33 UTC, Ali Çehreli wrote: On 9/13/22 04:07, test123 wrote: > On Tuesday, 13 September 2022 at 10:59:36 UTC, Dennis wrote: >> Side node, you can use `immutable` instead of `__gshared const`, it >> amounts to the same for global variables. > > because __enum

Re: can not take const struct member address at CTFE , is this a bug?

2022-09-14 Thread test123 via Digitalmars-d-learn
On Wednesday, 14 September 2022 at 14:41:38 UTC, Steven Schveighoffer wrote: On 9/14/22 12:53 AM, test123 wrote: On Wednesday, 14 September 2022 at 00:40:38 UTC, Ruby The Roobster wrote: The addresses of items stored in memory are by definition not constant.  This isn't a bug. If so why this

Re: can not take const struct member address at CTFE , is this a bug?

2022-09-15 Thread test123 via Digitalmars-d-learn
On Thursday, 15 September 2022 at 11:33:43 UTC, Dennis wrote: On Thursday, 15 September 2022 at 04:13:56 UTC, test123 wrote: I hope we have github bugs. It's being worked on. glad to know we are move into github. Please help me create a bug report if who has free time and bugs account. H

Is this a new bug ?

2022-09-23 Thread test123 via Digitalmars-d-learn
If so please report it for me to bugs platform. I can not register one. ```d package { version(TEST) { static: } else { __gshared: } uint test = 0; } ``` ldmd2 -betterC -vtls -c ./test.d ./test.d(7): `test` is thread local

Re: Is this a new bug ?

2022-09-24 Thread test123 via Digitalmars-d-learn
On Saturday, 24 September 2022 at 07:11:12 UTC, rikki cattermole wrote: ```d version(all) { __gshared: uint test2; } uint test; ``` Output with -vtls: ``` Up to 2.079.1: Success with output: onlineapp.d(9): test is thread local Since 2.080.1: Success with output: onlinea