Re: Thread local variables in betterC

2021-05-09 Thread Blatnik via Digitalmars-d-learn
On Sunday, 9 May 2021 at 22:55:41 UTC, Imperatorn wrote: Check the assembly I already did, here's the "wrong" version when I only run `$ dmd -betterC -m64 test.d`: ``` Dump of file test.obj main: pushrbp mov rbp,rsp mov rax,qword ptr gs:[58h] mov rcx

Re: Thread local variables in betterC

2021-05-09 Thread Blatnik via Digitalmars-d-learn
On Sunday, 9 May 2021 at 20:56:01 UTC, Ali Çehreli wrote: This is a long shot, but are you on OSX? I think TLS is handled specially for 32-bit OSX and that may somehow work in this case. (?) Nope, I'm on (64bit) windows. Another really weird thing is that if I compile this code in VisualD (w

Re: Thread local variables in betterC

2021-05-09 Thread Blatnik via Digitalmars-d-learn
On Sunday, 9 May 2021 at 18:46:18 UTC, rikki cattermole wrote: No. It is tied to druntime. I.e. on Linux it calls __tls_get_addr to get the address. Oh. I wish I got a warning about that from the compiler then >.> Also, why did it work for 32-bits then?

Thread local variables in betterC

2021-05-09 Thread Blatnik via Digitalmars-d-learn
Do thread local variables work in -betterC? Or maybe it's better to ask are they _supposed_ to work in -betterC? Here's a simple test program: ```D // test.d auto a; extern(C) void main() { printf("before... "); a = 42; printf("after"); } import core.stdc.stdio; ``` And here is the out

Re: Thread local variables in betterC

2021-05-09 Thread Blatnik via Digitalmars-d-learn
On Sunday, 9 May 2021 at 18:41:33 UTC, Blatnik wrote: Here's a simple test program: Whoops, `auto a` should be `int a`. Habits :P

Re: How to check for combinations of versions

2021-05-05 Thread Blatnik via Digitalmars-d-learn
On Wednesday, 5 May 2021 at 15:25:31 UTC, Paul Backus wrote: However, if you really want something more expressive, and are confident in your ability to use the extra power responsibly, it is possible to work around these limitations: template hasVersion(string identifier) { mixin(

How to check for combinations of versions

2021-05-05 Thread Blatnik via Digitalmars-d-learn
Is there any way to check for multiple conditions in a `version` statement? For example, my platform may have `Version_A` and `Version_B`, and both versions provide some shiny feature I want to use. Is there some nice way to write: ```D version (Version_A || Version_B) { // Use the cool fe

Re: How to automatically generate function overloads

2021-05-04 Thread Blatnik via Digitalmars-d-learn
On Tuesday, 4 May 2021 at 11:21:20 UTC, Zone wrote: ```D template Vectorize_Unary_Function(alias fun) { float[N] Vectorize_Unary_Function(size_t N)(float[N] vec) { float[N] result; static foreach (i; 0 .. N) result[i] = fun(vec[i]); return result; }

Re: How to automatically generate function overloads

2021-05-04 Thread Blatnik via Digitalmars-d-learn
On Tuesday, 4 May 2021 at 11:00:42 UTC, Blatnik wrote: How could I do this? I've already tried this: ```D mixin template Vectorize_Unary_Function(alias Function) { float[N] Function(size_t N)(float[N] vec) { float[N] result; static foreach (i; 0 .. N) result[i] = Function(vec

How to automatically generate function overloads

2021-05-04 Thread Blatnik via Digitalmars-d-learn
I'm porting over my linear algebra library from C++, and I have a bunch of functions that work on both scalars and vectors. The vector versions just apply the scalar function to every element of the vector, for example: ```D float clamp01(float x) { return x < 0 ? 0 : (x > 1 ? 1 : x); } float

Re: How do you compile DMD on Windows?

2021-05-02 Thread Blatnik via Digitalmars-d-learn
On Sunday, 2 May 2021 at 14:19:09 UTC, Imperatorn wrote: I opened the VS solution provided and pressed "build". Ta-daa! Haha yea, but wait until you try to build the runtime or phobos ;) I hope you don't have to/want to. But I can try to help if you do.

Re: How do you compile DMD on Windows?

2021-05-02 Thread Blatnik via Digitalmars-d-learn
On Sunday, 2 May 2021 at 00:53:42 UTC, MoonlightSentinel wrote: DM make is included in DMC which is available on this site, see the "other downloads". Yea thanks, I couldn't find it anywhere separately before. So in the end even though digger just worked, I didn't realize that it just install

Re: How do you compile DMD on Windows?

2021-05-01 Thread Blatnik via Digitalmars-d-learn
On Saturday, 1 May 2021 at 23:49:49 UTC, Blatnik wrote: Here's hoping that phobos isn't as annoying >.> It is just as annoying. Even after patching the paths, still errors out.. ``` C:\D\phobos>make -f win64.mak -j4 phobos64.lib cd etc\c\zlib "make" -f win64.mak MODEL=64 zlib64.lib "CC=C:\Pr

Re: How do you compile DMD on Windows?

2021-05-01 Thread Blatnik via Digitalmars-d-learn
On Saturday, 1 May 2021 at 23:07:35 UTC, MoonlightSentinel wrote: You probably need to update the VS paths to match your local installation, Microsoft apparently changed their directory layout a few years ago AFAICT. Thanks for the tip. I think I managed to get it to work.. So not only did I

How do you compile DMD on Windows?

2021-05-01 Thread Blatnik via Digitalmars-d-learn
I wanna hack on the compiler, but I've spend 3 hours and I can't get the damned thing to compile! Building DMD itself was simple since there was a visual studio project (thank you to whoever made it), but for druntime and phobos I can't figure it out. The instructions on https://wiki.dlang.o