Re: Exit before second main with -funittest

2021-07-30 Thread Brian TIffin via Digitalmars-d-learn
On Friday, 30 July 2021 at 22:51:00 UTC, Ali Çehreli wrote: On 7/30/21 3:08 PM, Brian Tiffin wrote: > Don't take to C++, never have, even while watching > cfront and Walter having the first** brain to craft a native compiler. [...] > ** I'm not sure Walter was first first, or close first,

Re: D compiler equivilent of "gcc -E" for debug/view template instantiation(generated) code?

2021-07-30 Thread dangbinghoo via Digitalmars-d-learn
On Friday, 30 July 2021 at 10:20:36 UTC, Stefan Koch wrote: On Friday, 30 July 2021 at 09:30:13 UTC, Mike Parker wrote: On Friday, 30 July 2021 at 08:38:24 UTC, dangbinghoo wrote: but, where's these switch option documented? it seems it not appears in dmd --help or man dmd, or online

Registering-unregistering threads

2021-07-30 Thread solidstate1991 via Digitalmars-d-learn
I'm doing some audio-related work, and one thing I need is to unregister from (and maybe later temporarily re-register to) the GC, since it would cause some issues, and it would be nice if I still could use the GC during disk operations, etc. Info on it is quite scarce and a bit confusing. If

Re: Exit before second main with -funittest

2021-07-30 Thread Ali Çehreli via Digitalmars-d-learn
On 7/30/21 3:08 PM, Brian Tiffin wrote: > Don't take to C++, never have, even while watching > cfront and Walter having the first** brain to craft a native compiler. [...] > ** I'm not sure Walter was first first, or close first, or... He wrote the first C++ compiler. (cfront was a C++-to-C

Re: Exit before second main with -funittest

2021-07-30 Thread Brian Tiffin via Digitalmars-d-learn
On Friday, 30 July 2021 at 08:26:47 UTC, Bastiaan Veelo wrote: On Friday, 30 July 2021 at 05:51:41 UTC, Brian Tiffin wrote: [... interesting account of the D experience ...] **Kudos team and contributors.** Can't really suggest that many improvements to resources needed for learning D, as a

Re: translate C struct char array into D

2021-07-30 Thread russhy via Digitalmars-d-learn
On Friday, 30 July 2021 at 14:05:58 UTC, workman wrote: I get want to define this struct in D: ```c struct test1 { struct test1 *prev; struct test1 *next; size_t v1; size_t v2; size_t v3; char data[]; }; ``` ```d struct test1 { test1 *prev; test1 *next;

Re: Performance issue with fiber

2021-07-30 Thread hanabi1224 via Digitalmars-d-learn
On Friday, 30 July 2021 at 14:41:06 UTC, Daniel Kozak wrote: I have rewrite it to be same as dart version Thanks! There're both generator version and fiber version on the site(if possible), the 2 versions are not really comparable to each other (generator solutions should be much faster).

Re: How to put an arbitrary string to clipboard in D?

2021-07-30 Thread rikki cattermole via Digitalmars-d-learn
On 31/07/2021 7:33 AM, tastyminerals wrote: I made a GUI app using tkd library. I am reading the string from one of the app widgets and would like to put it into the clipboard. Does anyone have an idea how to copy a string to the clipboard in D? copyText on a Text widget appears to do what

How to put an arbitrary string to clipboard in D?

2021-07-30 Thread tastyminerals via Digitalmars-d-learn
I made a GUI app using tkd library. I am reading the string from one of the app widgets and would like to put it into the clipboard. Does anyone have an idea how to copy a string to the clipboard in D?

Re: translate C struct char array into D

2021-07-30 Thread jfondren via Digitalmars-d-learn
On Friday, 30 July 2021 at 14:05:58 UTC, workman wrote: I get want to define this struct in D: ```c struct test1 { struct test1 *prev; struct test1 *next; size_t v1; size_t v2; size_t v3; char data[]; }; ``` The easy way: put a slice there instead of a fake array and

Re: translate C struct char array into D

2021-07-30 Thread Paul Backus via Digitalmars-d-learn
On Friday, 30 July 2021 at 15:51:12 UTC, Tejas wrote: On Friday, 30 July 2021 at 14:40:17 UTC, Paul Backus wrote: On Friday, 30 July 2021 at 14:05:58 UTC, workman wrote: [...] `char data[]` in the C struct is not a pointer, but actually a [C99 flexible array member][1], and does not count

Re: translate C struct char array into D

2021-07-30 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jul 30, 2021 at 03:41:32PM +, Tejas via Digitalmars-d-learn wrote: > On Friday, 30 July 2021 at 14:40:17 UTC, Paul Backus wrote: [...] > > ```d > > struct test1 { > > // member variables... > > > > char* data() { > > return cast(char*) ( + 1); > > } > > } > > ``` >

Re: translate C struct char array into D

2021-07-30 Thread Tejas via Digitalmars-d-learn
On Friday, 30 July 2021 at 14:40:17 UTC, Paul Backus wrote: On Friday, 30 July 2021 at 14:05:58 UTC, workman wrote: [...] `char data[]` in the C struct is not a pointer, but actually a [C99 flexible array member][1], and does not count towards the struct's `sizeof`. D does not have

Re: translate C struct char array into D

2021-07-30 Thread Tejas via Digitalmars-d-learn
On Friday, 30 July 2021 at 14:40:17 UTC, Paul Backus wrote: On Friday, 30 July 2021 at 14:05:58 UTC, workman wrote: [...] `char data[]` in the C struct is not a pointer, but actually a [C99 flexible array member][1], and does not count towards the struct's `sizeof`. D does not have

Re: translate C struct char array into D

2021-07-30 Thread Paul Backus via Digitalmars-d-learn
On Friday, 30 July 2021 at 14:05:58 UTC, workman wrote: I get want to define this struct in D: ```c struct test1 { struct test1 *prev; struct test1 *next; size_t v1; size_t v2; size_t v3; char data[]; }; ``` ```d struct test1 { test1 *prev; test1 *next;

Re: Performance issue with fiber

2021-07-30 Thread Daniel Kozak via Digitalmars-d-learn
On Wed, Jul 28, 2021 at 11:41 PM hanabi1224 via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > On Wednesday, 28 July 2021 at 16:26:49 UTC, drug wrote: > > I profiled the provided example (not `FiberScheduler`) using > > perf. Both dmd and ldc2 gave the same result - `void > >

translate C struct char array into D

2021-07-30 Thread workman via Digitalmars-d-learn
I get want to define this struct in D: ```c struct test1 { struct test1 *prev; struct test1 *next; size_t v1; size_t v2; size_t v3; char data[]; }; ``` ```d struct test1 { test1 *prev; test1 *next; size_t v1; size_t v2; size_t v3; char* data; };

Re: D compiler equivilent of "gcc -E" for debug/view template instantiation(generated) code?

2021-07-30 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 30 July 2021 at 09:30:13 UTC, Mike Parker wrote: On Friday, 30 July 2021 at 08:38:24 UTC, dangbinghoo wrote: but, where's these switch option documented? it seems it not appears in dmd --help or man dmd, or online document https://dlang.org/dmd-linux.html That's what he

Re: D compiler equivilent of "gcc -E" for debug/view template instantiation(generated) code?

2021-07-30 Thread dangbinghoo via Digitalmars-d-learn
On Friday, 30 July 2021 at 09:30:13 UTC, Mike Parker wrote: On Friday, 30 July 2021 at 08:38:24 UTC, dangbinghoo wrote: but, where's these switch option documented? it seems it not appears in dmd --help or man dmd, or online document https://dlang.org/dmd-linux.html That's what he

Re: D compiler equivilent of "gcc -E" for debug/view template instantiation(generated) code?

2021-07-30 Thread Mike Parker via Digitalmars-d-learn
On Friday, 30 July 2021 at 08:38:24 UTC, dangbinghoo wrote: but, where's these switch option documented? it seems it not appears in dmd --help or man dmd, or online document https://dlang.org/dmd-linux.html That's what he meant by "hidden" switch. I don't know why it isn't documented,

Re: D compiler equivilent of "gcc -E" for debug/view template instantiation(generated) code?

2021-07-30 Thread dangbinghoo via Digitalmars-d-learn
On Friday, 30 July 2021 at 06:46:18 UTC, WebFreak001 wrote: On Friday, 30 July 2021 at 06:00:41 UTC, dangbinghoo wrote: Not sure if this is exactly what you want but there is a hidden switch in dmd called `-vcg-ast` that prints out all the templates instantiated. but, where's these

Re: Exit before second main with -funittest

2021-07-30 Thread Bastiaan Veelo via Digitalmars-d-learn
On Friday, 30 July 2021 at 05:51:41 UTC, Brian Tiffin wrote: [... interesting account of the D experience ...] **Kudos team and contributors.** Can't really suggest that many improvements to resources needed for learning D, as a hobbyist not on a clock, being new still and low enough to not

Re: D compiler equivilent of "gcc -E" for debug/view template instantiation(generated) code?

2021-07-30 Thread dangbinghoo via Digitalmars-d-learn
On Friday, 30 July 2021 at 06:46:18 UTC, WebFreak001 wrote: On Friday, 30 July 2021 at 06:00:41 UTC, dangbinghoo wrote: Not sure if this is exactly what you want but there is a hidden switch in dmd called `-vcg-ast` that prints out all the templates instantiated. On run.dlang.io you can use

Re: D compiler equivilent of "gcc -E" for debug/view template instantiation(generated) code?

2021-07-30 Thread WebFreak001 via Digitalmars-d-learn
On Friday, 30 July 2021 at 06:00:41 UTC, dangbinghoo wrote: hi, is there any D compiler option or other method to view the final template instantiation but not compiled (in asm or binary) code? if there's a way, it might be very usefull for newbies like me to learn and understand the the

Re: Exit before second main with -funittest

2021-07-30 Thread Ali Çehreli via Digitalmars-d-learn
On 7/29/21 9:22 PM, Mathias LANG wrote: > On Friday, 30 July 2021 at 03:45:21 UTC, Ali Çehreli wrote: >> Almost all of my programs are in the following pattern: >> >> ```D >> import std.stdio; >> >> void main(string[] args) { >> version (unittest) { >> // Don't execute the main program

D compiler equivilent of "gcc -E" for debug/view template instantiation(generated) code?

2021-07-30 Thread dangbinghoo via Digitalmars-d-learn
hi, is there any D compiler option or other method to view the final template instantiation but not compiled (in asm or binary) code? if there's a way, it might be very usefull for newbies like me to learn and understand the the Meta programming of dlang. thanks! dbh