Re: Remove own post from forum

2021-05-09 Thread Paul Backus via Digitalmars-d-learn
On Monday, 10 May 2021 at 03:36:02 UTC, Виталий Фадеев wrote: I have missformated post in thread: https://forum.dlang.org/thread/kwpqyzwgczdpzgsvo...@forum.dlang.org Say, please, how to remove own post from this forum ? There's currently no way to remove or edit an existing post.

Remove own post from forum

2021-05-09 Thread Виталий Фадеев via Digitalmars-d-learn
I have missformated post in thread: https://forum.dlang.org/thread/kwpqyzwgczdpzgsvo...@forum.dlang.org Say, please, how to remove own post from this forum ?

Re: alias & local function

2021-05-09 Thread Alain De Vos via Digitalmars-d-learn
This one runs fine, ``` import std.stdio; void main() { static int Gfunction(int x){return x;} int Lfunction(int x){return x;} alias gfunction = int function(int); alias lfunction = int delegate(int); gfunction g = &

Re: alias & local function

2021-05-09 Thread Basile B. via Digitalmars-d-learn
On Monday, 10 May 2021 at 01:25:10 UTC, Alain De Vos wrote: This does not: ``` import std.stdio; void main() { int afunction(int x){return x;}; it's not static so -> context -> delegate alias myint = int; myint i=5;

Re: alias & local function

2021-05-09 Thread Alain De Vos via Digitalmars-d-learn
I see. Just like in Java.

Re: alias & local function

2021-05-09 Thread Alain De Vos via Digitalmars-d-learn
I wonder why ?

alias & local function

2021-05-09 Thread Alain De Vos via Digitalmars-d-learn
The following program runs correctly ``` import std.stdio; int afunction(int x){return x;}; void main() { alias myint = int; myint i=5; alias tfunction = int function(int); tfunction f = & afunction; writeln(f(1)); }

Is it possible to run a single unittest without an external library?

2021-05-09 Thread Anthony via Digitalmars-d-learn
Hello, I'm trying to setup a minimal testing process with unittest. However, I would like to run the tests of a single file to keep things fast. At the moment, it runs all unittests that are imported with a file. eg. `rdmd -I... source/foo.d` will run unittests bar.d if it is imported into

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

Re: Thread local variables in betterC

2021-05-09 Thread Imperatorn via Digitalmars-d-learn
On Sunday, 9 May 2021 at 21:42:54 UTC, Blatnik wrote: 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

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

Re: Thread local variables in betterC

2021-05-09 Thread Ali Çehreli via Digitalmars-d-learn
On 5/9/21 11:49 AM, Blatnik wrote: Also, why did it work for 32-bits then? 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. (?) Ali

Re: Cannot access frame pointer of a struct with member function

2021-05-09 Thread Andrey Zherikov via Digitalmars-d-learn
On Sunday, 9 May 2021 at 17:53:07 UTC, SealabJaster wrote: On Sunday, 9 May 2021 at 17:37:40 UTC, Andrey Zherikov wrote: Is this a bug? My best guess is that, since the struct doesn't have any member functions the compiler has decided that the struct doesn't need any access to the main

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?

Re: Thread local variables in betterC

2021-05-09 Thread rikki cattermole via Digitalmars-d-learn
On 10/05/2021 6:41 AM, Blatnik wrote: Do thread local variables work in -betterC? Or maybe it's better to ask are they _supposed_ to work in -betterC? No. It is tied to druntime. I.e. on Linux it calls __tls_get_addr to get the address.

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

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: Cannot access frame pointer of a struct with member function

2021-05-09 Thread SealabJaster via Digitalmars-d-learn
On Sunday, 9 May 2021 at 17:37:40 UTC, Andrey Zherikov wrote: ... https://run.dlang.io/is/sCUdXe shows this a bit more clearly.

Re: Cannot access frame pointer of a struct with member function

2021-05-09 Thread SealabJaster via Digitalmars-d-learn
On Sunday, 9 May 2021 at 17:37:40 UTC, Andrey Zherikov wrote: Is this a bug? My best guess is that, since the struct doesn't have any member functions the compiler has decided that the struct doesn't need any access to the main function's context/frame pointer, so the struct has implicitly

Re: Cannot access frame pointer of a struct with member function

2021-05-09 Thread evilrat via Digitalmars-d-learn
On Sunday, 9 May 2021 at 17:37:40 UTC, Andrey Zherikov wrote: Compilation of this code: ```d auto foo(T)() { return T(); // Error: cannot access frame pointer of `onlineapp.main.T` } void main() { struct T { int a=1; void argsFunc(int a) {} // (1) }

Cannot access frame pointer of a struct with member function

2021-05-09 Thread Andrey Zherikov via Digitalmars-d-learn
Compilation of this code: ```d auto foo(T)() { return T(); // Error: cannot access frame pointer of `onlineapp.main.T` } void main() { struct T { int a=1; void argsFunc(int a) {} // (1) } pragma(msg,foo!T()); } ``` fails with this error: ```

Re: Is there any bettter solution to Windows wide string

2021-05-09 Thread Vinod K Chandran via Digitalmars-d-learn
On Sunday, 9 May 2021 at 09:34:00 UTC, FreeSlave wrote: You may try using tempCStringW from std.internal.cstring. It uses small string optimization. However the api is internal, so I'm not sure how valid it is to use this function. The returned struct is a temporary buffer so you must

Re: Templated class requires values even though having default value

2021-05-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 9 May 2021 at 10:53:49 UTC, tcak wrote: The "dim" template parameter has a default value of 1 already. Why does it still force me to give a value? It doesn't, but it does require you to instantiate the template. You can do `OpenClKernel!()` to use the default value. But without

Templated class requires values even though having default value

2021-05-09 Thread tcak via Digitalmars-d-learn
public class OpenCLKernel(size_t dim = 1) if( (dim >= 1) && (dim <= 3) ) { public this( OpenCLProgram program, in string kernelName ) { // ... } } I have a class definition as above. When I want to create

Re: Is there any bettter solution to Windows wide string

2021-05-09 Thread FreeSlave via Digitalmars-d-learn
On Saturday, 8 May 2021 at 20:50:10 UTC, Vinod K Chandran wrote: Hi all, I am planning some win32 hobby projects. Now I have this function to tackle the LPCWSTR data type in win32. ```d private import std.utf; auto toWString(S)(S s) { return toUTFz!(const(wchar)*)(s); } ``` Is there any better