Re: While loop on global variable optimised away?

2022-05-11 Thread ichneumwn via Digitalmars-d-learn
On Wednesday, 11 May 2022 at 10:01:18 UTC, Johan wrote: Any function call (inside the loop) for which it cannot be proven that it never modifies your memory variable will work. That's why I'm pretty sure that mutex lock/unlock will work. Thank you, in C I would not have been surprised. It

While loop on global variable optimised away?

2022-05-11 Thread ichneumwn via Digitalmars-d-learn
Hi Forum, I have a snippet of code as follows: ``` extern(C) extern __gshared uint g_count; // inside a class member function: while(g_count) <= count) {} ``` This is from a first draft of the code without proper thread synchronisation. The global variable g_count is updated from a bit of

Re: Use bindbc-sdl statically

2021-04-24 Thread ichneumwn via Digitalmars-d-learn
On Saturday, 24 April 2021 at 16:44:09 UTC, Ishax wrote: So I have the lib files. It's failing with only an exit code. No window is appearing. It's using the same D code as with the dynamic setup which I was able to produce a window with. ```sdl dependency "bindbc-sdl" version="~>0.1.0"

Re: Dlang equivalent of #define/#ifdef : not... version

2021-04-21 Thread ichneumwn via Digitalmars-d-learn
On Tuesday, 20 April 2021 at 18:57:46 UTC, ichneumwn wrote: Hi, Trying to convert a C header to D. The underlying package exists in different versions and may or may not expose certain functionality (modules/extensions). One should check at compile time that the header provides the relevant

Re: write once type?

2021-04-20 Thread ichneumwn via Digitalmars-d-learn
On Tuesday, 20 April 2021 at 20:04:17 UTC, Steven Schveighoffer wrote: I just realized, this is Rebindable, or tail-const. (I don't need the head to be truly const, I just need to be able to copy into a const-referring thing). I currently am using a pointer, which is working, but I prefer not

Re: write once type?

2021-04-20 Thread ichneumwn via Digitalmars-d-learn
On Tuesday, 20 April 2021 at 19:56:33 UTC, Steven Schveighoffer wrote: I have had the need in some cases to *maybe* set a const value inside a loop. One can sometimes abstract this into a lambda function, but sometimes this is not possible (e.g. if the loop is static). Not only that, but I may

Dlang equivalent of #define/#ifdef : not... version

2021-04-20 Thread ichneumwn via Digitalmars-d-learn
Hi, Trying to convert a C header to D. The underlying package exists in different versions and may or may not expose certain functionality (modules/extensions). One should check at compile time that the header provides the relevant definitions, through #ifdef, and do a further run-time check

Re: Linux shared library loading/linking from C does not invoke (shared) static this

2021-01-12 Thread ichneumwn via Digitalmars-d-learn
On Tuesday, 12 January 2021 at 09:49:46 UTC, Mike Parker wrote: On Tuesday, 12 January 2021 at 09:31:08 UTC, ichneumwn wrote: Follow on to my own question: on Linux, with gcc, I have created the following file "starter.c" that I inject into my D shared library: int rt_init(void); int

Re: Linux shared library loading/linking from C does not invoke (shared) static this

2021-01-12 Thread ichneumwn via Digitalmars-d-learn
On Tuesday, 12 January 2021 at 09:02:38 UTC, Imperatorn wrote: On Tuesday, 12 January 2021 at 08:19:45 UTC, ichneumwn wrote: Where could one file a suggestion for an update to the documentation? In the top right section of the page you can click the "Improve this page"-link. Thanks, I will

Re: Linux shared library loading/linking from C does not invoke (shared) static this

2021-01-12 Thread ichneumwn via Digitalmars-d-learn
On Tuesday, 12 January 2021 at 08:19:45 UTC, ichneumwn wrote: Dear all, I was trying to invoke some D code from Python and ran into issues which I eventually traced back to a simple example on the D website itself : https://dlang.org/articles/dll-linux.html Particularly the section

Linux shared library loading/linking from C does not invoke (shared) static this

2021-01-12 Thread ichneumwn via Digitalmars-d-learn
Dear all, I was trying to invoke some D code from Python and ran into issues which I eventually traced back to a simple example on the D website itself : https://dlang.org/articles/dll-linux.html Particularly the section "Dynamically Loading a D DLL From a C Program" In my case, and

Re: Waiting on file descriptor/socket *AND* thread messages

2020-06-29 Thread ichneumwn via Digitalmars-d-learn
On Monday, 29 June 2020 at 12:25:16 UTC, Steven Schveighoffer wrote: On 6/29/20 5:14 AM, ichneumwn wrote: [...] Not in the standard library. Such things require an event framework, because there is no OS-agnostic provided mechanism to sleep on all these things at once. I recommend looking

Waiting on file descriptor/socket *AND* thread messages

2020-06-29 Thread ichneumwn via Digitalmars-d-learn
Dear all, Is there some facility in D for a single statement/function call that will wait on both file descriptors, like Socket.select(), and will also wake up when there is something to be receive()'d? One solution would be to have my main thread use receive() and a helper thread that does