Re: dub does not correctly link on Macbook Pro 2019 (intel)
On Sunday, 20 August 2023 at 01:32:08 UTC, Alexander wrote: On Saturday, 19 August 2023 at 22:53:53 UTC, Sergey wrote: [...] Thanks for the advice: I have installed dmd, dub, and now ldc with brew. Versions below: [...] Just to add my MacOS version: % sw_vers ``` ProductName:macOS ProductVersion: 13.5 BuildVersion: 22G74 ```
Re: dub does not correctly link on Macbook Pro 2019 (intel)
On Sunday, 20 August 2023 at 01:12:56 UTC, Kyle Ingraham wrote: On Saturday, 19 August 2023 at 22:53:53 UTC, Sergey wrote: On Saturday, 19 August 2023 at 21:35:25 UTC, Alexander wrote: Completely new to D, and when trying to setup the toolchain, Could you please specify the versions of macOS and DMD? Probably DMD is broken for macOS - could you try to use LDC? Maybe this thread is relative to the problem: https://github.com/ldc-developers/ldc/issues/3864 I think that thread is where I originally found the bandaid I described: https://github.com/ldc-developers/ldc/issues/3864#issuecomment-963304679 Setting MACOSX_DEPLOYMENT_TARGET=12 allows dub to work with dmd. It's when I don't have it set, or set to 13 that I get those linker errors. Maybe this would have been obvious to a C or C++ developer, but I do all my professional development on scala and python, and c# before that. I now have 2 working D compilers, thank you for your help.
Re: dub does not correctly link on Macbook Pro 2019 (intel)
On Saturday, 19 August 2023 at 22:53:53 UTC, Sergey wrote: On Saturday, 19 August 2023 at 21:35:25 UTC, Alexander wrote: Completely new to D, and when trying to setup the toolchain, Could you please specify the versions of macOS and DMD? Probably DMD is broken for macOS - could you try to use LDC? Maybe this thread is relative to the problem: https://github.com/ldc-developers/ldc/issues/3864 Thanks for the advice: I have installed dmd, dub, and now ldc with brew. Versions below: % dmd --version ``` DMD64 D Compiler v2.105.0 Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved written by Walter Bright ``` % dub --version ``` DUB version 1.34.0, built on Aug 1 2023 pacs@PACS-2019-MBPRO ~ % sw_vers ProductName:macOS ProductVersion: 13.5 BuildVersion: 22G74 ``` % ldc2 --version ``` LDC - the LLVM D compiler (1.33.0): based on DMD v2.103.1 and LLVM 15.0.7 built with LDC - the LLVM D compiler (1.28.1) Default target: x86_64-apple-darwin22.6.0 Host CPU: skylake http://dlang.org - http://wiki.dlang.org/LDC Registered Targets: ... ``` % cat ~/.dub/settings.json ``` { "defaultArchitecture": "x86_64", "defaultCompiler": "ldc2" } ``` (where defaultCompiler had been dmd before). % dub run ``` Starting Performing "debug" build using ldc2 for x86_64. Up-to-date hellod ~master: target for configuration [application] is up to date. Finished To force a rebuild of up-to-date targets, run again with --force Running hellod Edit source/app.d to start your project. ``` So, ldc2 seems to work with dub, where dmd did not. The odd thing though is, if you refer to my original post, is that I was able to build successfully by directly invoking dmd.
Re: dub does not correctly link on Macbook Pro 2019 (intel)
On Saturday, 19 August 2023 at 22:53:53 UTC, Sergey wrote: On Saturday, 19 August 2023 at 21:35:25 UTC, Alexander wrote: Completely new to D, and when trying to setup the toolchain, Could you please specify the versions of macOS and DMD? Probably DMD is broken for macOS - could you try to use LDC? Maybe this thread is relative to the problem: https://github.com/ldc-developers/ldc/issues/3864 I think that thread is where I originally found the bandaid I described: https://github.com/ldc-developers/ldc/issues/3864#issuecomment-963304679
Re: dub does not correctly link on Macbook Pro 2019 (intel)
On Saturday, 19 August 2023 at 21:35:25 UTC, Alexander wrote: Completely new to D, and when trying to setup the toolchain, DMD seems to work fine, but dub is running into linker issues. On my Intel iMac I have to set `MACOSX_DEPLOYMENT_TARGET`: ``` MACOSX_DEPLOYMENT_TARGET=11 dub run ``` That puts a bandaid on the linker issues. I haven’t yet set aside time to report it as an issue.
Re: dub does not correctly link on Macbook Pro 2019 (intel)
On Saturday, 19 August 2023 at 21:35:25 UTC, Alexander wrote: Completely new to D, and when trying to setup the toolchain, Could you please specify the versions of macOS and DMD? Probably DMD is broken for macOS - could you try to use LDC? Maybe this thread is relative to the problem: https://github.com/ldc-developers/ldc/issues/3864
dub does not correctly link on Macbook Pro 2019 (intel)
Completely new to D, and when trying to setup the toolchain, DMD seems to work fine, but dub is running into linker issues. Below is session showing a simple hello world directory initialized with dub init, and the issues I am encountering. Any help would be greatly appreciated: % tree ``` . ├── dub.json └── source └── app.d 2 directories, 2 files ``` pacs@PACS-2019-MBPRO hellod % cat dub.json ``` { "name": "hellod" } ``` % cat source/app.d ``` import std.stdio; void main() { writeln("Edit source/app.d to start your project."); } ``` % dub run ``` Starting Performing "debug" build using dmd for x86_64. Building hellod ~master: building configuration [application] Linking hellod ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers ld: warning: pointer not aligned at address 0x1000681CE ('anon' + 462 from /Users/pacs/.dub/cache/hellod/~master/build/application-debug-g5hl-T2MblAlsFiv_Yxjpw/h ellod.o) ld: warning: pointer not aligned at address 0x1000681E7 ('anon' + 487 from /Users/pacs/.dub/cache/hellod/~master/build/application-debug-g5hl-T2MblAlsFiv_Yxjpw/h ellod.o) ld: warning: pointer not aligned at address 0x1000682E7 ('anon' + 743 from /Users/pacs/.dub/cache/hellod/~master/build/application-debug-g5hl-T2MblAlsFiv_Yxjpw/h ellod.o) ld: warning: pointer not aligned at address 0x10006832F ('anon' + 815 from /Users/pacs/.dub/cache/hellod/~master/build/application-debug-g5hl-T2MblAlsFiv_Yxjpw/h ellod.o) ld: warning: pointer not aligned at address 0x100068385 ('anon' + 901 from /Users/pacs/.dub/cache/hellod/~master/build/application-debug-g5hl-T2MblAlsFiv_Yxjpw/h ellod.o) ld: warning: pointer not aligned at address 0x100068446 ('anon' + 1094 from /Users/pacs/.dub/cache/hellod/~master/build/application-debug-g5hl-T2MblAlsFiv_Yxjpw/ hellod.o) ld: warning: pointer not aligned at address 0x100068462 ('anon' + 1122 from /Users/pacs/.dub/cache/hellod/~master/build/application-debug-g5hl-T2MblAlsFiv_Yxjpw/ hellod.o) ld: unaligned pointer(s) for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) Error: linker exited with status 1 Error dmd failed with exit code 1. ``` % cd source % dmd app.d % ls -l ``` total 1688 -rwxr-xr-x@ 1 pacs staff 842616 Aug 19 16:30 app -rw-r--r--@ 1 pacs staff 89 Aug 19 02:46 app.d -rw-r--r--@ 1 pacs staff 15496 Aug 19 16:30 app.o ``` % otool -L app ``` app: /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.100.3) ``` % file app ``` app: Mach-O 64-bit executable x86_64 ``` % ./app ``` Edit source/app.d to start your project. ```
Re: How can I execute C++ functions from Dlang?
On Saturday, 19 August 2023 at 20:50:23 UTC, thePengüin wrote: On Saturday, 19 August 2023 at 20:16:47 UTC, Ferhat Kurtulmuş wrote: On Saturday, 19 August 2023 at 19:41:47 UTC, thePengüin wrote: On Monday, 14 August 2023 at 07:36:31 UTC, Ferhat Kurtulmuş wrote: [...] estoy usando el de 64 o almenos eso es lo que me dice cuando hago un dmd --version: DMD64 D Compiler v2.104.2-dirty Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved written by Walter Bright por cierto "cl" en ves de g++, creo que es la abreviatura de "compilador" no? porque cl no me sale como comando en el mingw64x84 Estoy escribendo en mi celular. Entonces no tomo ayudar de Google translate. Mi español no es bueno, disculpa. Nunca uso un mesclar de mingw-g++ y algun d compilador en Windows. cl es el comando del Visual C++. No sé si g++ y dmd son binarias compatibles. Yo siempre uso LDC en Windows. Creo que tu deberias installar e uso Visual studio c++ community edition. Los compiladores msvc juega bien con los compiladores de dlang. Que es cl.exe: https://learn.microsoft.com/en-us/cpp/build/reference/compiler-options?view=msvc-170 - te refieres al ldc de Dlang en windows no? Sí, yo queria decir esto. Lo puedes descargar aqui: https://github.com/ldc-developers/ldc/releases/tag/v1.33.0 Por favor te recorda que cuando tu installaste msvc, siempre ejecuta tus comandos del compiladores (cl, ldc2 o dmd, etc.) en terminal del msvc. Puedes buscarlo en menu de inicio de windows porque automatiza link con bibliotheca de stdc++.
Re: Mir-algorithm tutorial?
On Saturday, 19 August 2023 at 08:59:40 UTC, Ferhat Kurtulmuş wrote: On Saturday, 19 August 2023 at 01:44:16 UTC, Kyle Ingraham wrote: On Friday, 18 August 2023 at 12:14:45 UTC, Ferhat Kurtulmuş wrote: I think the main problem is the mir libraries won't get updates since Ilya recently said that he was not an open source developer anymore. That’s unfortunate for D but hopefully beneficial for Ilya. Was it said somewhere publicly where I can read more on it? https://forum.dlang.org/post/u7r1i8$rn7$1...@digitalmars.com Much appreciated Ferhat.
Re: How can I execute C++ functions from Dlang?
On Saturday, 19 August 2023 at 20:16:47 UTC, Ferhat Kurtulmuş wrote: On Saturday, 19 August 2023 at 19:41:47 UTC, thePengüin wrote: On Monday, 14 August 2023 at 07:36:31 UTC, Ferhat Kurtulmuş wrote: On Monday, 14 August 2023 at 06:40:04 UTC, thePengüin wrote: hola a todos quisiera ejecutar este codigo de c++ ` #include \ using namespace std; int main() { return 0; } int foo(int i, int j) { cout \<\< i\<\ ?Tu usas ambos de 64 bit o 32 bit para compiladores? No puedo reproducir tu codigo. Pero yo puedo ejecutar esto en Windows: cppcode.cpp ```d #include using namespace std; // no nececitamos un main aqui int foo(int i, int j) { cout << i << endl; cout << j << endl; return 7; } ``` main.d ```d extern(C++) int foo(int i, int j); void main () { foo(3,6); } ``` La compulacion: cl cppcode.cpp -c dmd main.d cppcode.obj estoy usando el de 64 o almenos eso es lo que me dice cuando hago un dmd --version: DMD64 D Compiler v2.104.2-dirty Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved written by Walter Bright por cierto "cl" en ves de g++, creo que es la abreviatura de "compilador" no? porque cl no me sale como comando en el mingw64x84 Estoy escribendo en mi celular. Entonces no tomo ayudar de Google translate. Mi español no es bueno, disculpa. Nunca uso un mesclar de mingw-g++ y algun d compilador en Windows. cl es el comando del Visual C++. No sé si g++ y dmd son binarias compatibles. Yo siempre uso LDC en Windows. Creo que tu deberias installar e uso Visual studio c++ community edition. Los compiladores msvc juega bien con los compiladores de dlang. Que es cl.exe: https://learn.microsoft.com/en-us/cpp/build/reference/compiler-options?view=msvc-170 - te refieres al ldc de Dlang en windows no?
Re: How can I execute C++ functions from Dlang?
On Saturday, 19 August 2023 at 20:16:47 UTC, Ferhat Kurtulmuş wrote: On Saturday, 19 August 2023 at 19:41:47 UTC, thePengüin wrote: On Monday, 14 August 2023 at 07:36:31 UTC, Ferhat Kurtulmuş wrote: On Monday, 14 August 2023 at 06:40:04 UTC, thePengüin wrote: hola a todos quisiera ejecutar este codigo de c++ ` #include \ using namespace std; int main() { return 0; } int foo(int i, int j) { cout \<\< i\<\ ?Tu usas ambos de 64 bit o 32 bit para compiladores? No puedo reproducir tu codigo. Pero yo puedo ejecutar esto en Windows: cppcode.cpp ```d #include using namespace std; // no nececitamos un main aqui int foo(int i, int j) { cout << i << endl; cout << j << endl; return 7; } ``` main.d ```d extern(C++) int foo(int i, int j); void main () { foo(3,6); } ``` La compulacion: cl cppcode.cpp -c dmd main.d cppcode.obj estoy usando el de 64 o almenos eso es lo que me dice cuando hago un dmd --version: DMD64 D Compiler v2.104.2-dirty Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved written by Walter Bright por cierto "cl" en ves de g++, creo que es la abreviatura de "compilador" no? porque cl no me sale como comando en el mingw64x84 Estoy escribendo en mi celular. Entonces no tomo ayudar de Google translate. Mi español no es bueno, disculpa. Nunca uso un mesclar de mingw-g++ y algun d compilador en Windows. cl es el comando del Visual C++. No sé si g++ y dmd son binarias compatibles. Yo siempre uso LDC en Windows. Creo que tu deberias installar e uso Visual studio c++ community edition. Los compiladores msvc juega bien con los compiladores de dlang. Que es cl.exe: https://learn.microsoft.com/en-us/cpp/build/reference/compiler-options?view=msvc-170 - ok, don't worry, Your spanish is so right, hehe I don't actually english cause I'm feel lazy xd. - gracias no sabia que existia el Visual C++, gracias por el dato ahora mismo lo busco.
Re: How can I execute C++ functions from Dlang?
On Saturday, 19 August 2023 at 19:41:47 UTC, thePengüin wrote: On Monday, 14 August 2023 at 07:36:31 UTC, Ferhat Kurtulmuş wrote: On Monday, 14 August 2023 at 06:40:04 UTC, thePengüin wrote: hola a todos quisiera ejecutar este codigo de c++ ` #include \ using namespace std; int main() { return 0; } int foo(int i, int j) { cout \<\< i\<\ ?Tu usas ambos de 64 bit o 32 bit para compiladores? No puedo reproducir tu codigo. Pero yo puedo ejecutar esto en Windows: cppcode.cpp ```d #include using namespace std; // no nececitamos un main aqui int foo(int i, int j) { cout << i << endl; cout << j << endl; return 7; } ``` main.d ```d extern(C++) int foo(int i, int j); void main () { foo(3,6); } ``` La compulacion: cl cppcode.cpp -c dmd main.d cppcode.obj estoy usando el de 64 o almenos eso es lo que me dice cuando hago un dmd --version: DMD64 D Compiler v2.104.2-dirty Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved written by Walter Bright por cierto "cl" en ves de g++, creo que es la abreviatura de "compilador" no? porque cl no me sale como comando en el mingw64x84 Estoy escribendo en mi celular. Entonces no tomo ayudar de Google translate. Mi español no es bueno, disculpa. Nunca uso un mesclar de mingw-g++ y algun d compilador en Windows. cl es el comando del Visual C++. No sé si g++ y dmd son binarias compatibles. Yo siempre uso LDC en Windows. Creo que tu deberias installar e uso Visual studio c++ community edition. Los compiladores msvc juega bien con los compiladores de dlang. Que es cl.exe: https://learn.microsoft.com/en-us/cpp/build/reference/compiler-options?view=msvc-170
Re: How can I execute C++ functions from Dlang?
On Monday, 14 August 2023 at 07:36:31 UTC, Ferhat Kurtulmuş wrote: On Monday, 14 August 2023 at 06:40:04 UTC, thePengüin wrote: hola a todos quisiera ejecutar este codigo de c++ ` #include \ using namespace std; int main() { return 0; } int foo(int i, int j) { cout \<\< i\<\ ?Tu usas ambos de 64 bit o 32 bit para compiladores? No puedo reproducir tu codigo. Pero yo puedo ejecutar esto en Windows: cppcode.cpp ```d #include using namespace std; // no nececitamos un main aqui int foo(int i, int j) { cout << i << endl; cout << j << endl; return 7; } ``` main.d ```d extern(C++) int foo(int i, int j); void main () { foo(3,6); } ``` La compulacion: cl cppcode.cpp -c dmd main.d cppcode.obj estoy usando el de 64 o almenos eso es lo que me dice cuando hago un dmd --version: DMD64 D Compiler v2.104.2-dirty Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved written by Walter Bright por cierto "cl" en ves de g++, creo que es la abreviatura de "compilador" no? porque cl no me sale como comando en el mingw64x84
Re: How can I execute C++ functions from Dlang?
On Monday, 14 August 2023 at 07:38:46 UTC, Sergey wrote: On Monday, 14 August 2023 at 06:40:04 UTC, thePengüin wrote: hola a todos quisiera ejecutar este codigo de c++ Error: linker exited with status 1 Hola. On the page https://dlang.org/spec/cpp_interface.html commands to run also have different flags. Did you try them? g++ -c foo.cpp dmd bar.d foo.o -L-lstdc++ && ./bar estoy en windows y me sale este error: Error: unrecognized file extension o el g++ -c me da de resultado un archivo con .o y el dmd solo me permite con .obj pero ni aun asi me funciona
Re: How can I execute C++ functions from Dlang?
On Monday, 14 August 2023 at 07:36:31 UTC, Ferhat Kurtulmuş wrote: On Monday, 14 August 2023 at 06:40:04 UTC, thePengüin wrote: [...] ?Tu usas ambos de 64 bit o 32 bit para compiladores? No puedo reproducir tu codigo. Pero yo puedo ejecutar esto en Windows: cppcode.cpp ```d #include using namespace std; // no nececitamos un main aqui int foo(int i, int j) { cout << i << endl; cout << j << endl; return 7; } ``` main.d ```d extern(C++) int foo(int i, int j); void main () { foo(3,6); } ``` La compulacion: cl cppcode.cpp -c dmd main.d cppcode.obj que compilador estas usando a la hora de hacer el del .cpp
Spec for the ‘locality’ parameter to the LDC and GDC builtin magic functions for accessing special CPU prefetch instructions
I’m trying to write a cross-platform function that gives access to the CPU’s prefetch instructions such as x86 prefetch0/1/2/prefetchnta and AAarch64 too. I’ve found that the GDC and LDC compilers provide builtin magic functions for this, and are what I need. I am trying to put together a plain-English detailed spec for the respective builtin magic functions. My questions: Q1) I need to compare the spec for the GCC and LDC builtin magic functions’ "locality" parameter. Can anyone tell me if GDC and LDC have kept mutual compatibility here? Q2) Could someone help me turn the GCC and LDC specs into english regarding the locality parameter ? - see (2) and (4) below. Q3) Does the locality parameter determine which _level_ of the data cache hierarchy data is fetched into? Or is it always fetched into L1 data cache and the outer ones, and this parameter affects caches’ _future behaviour_? Q3) Will these magic builtins work on AAarch64? Here’s what I’ve found so far 1. GCC builtin published by the D runtime: import gcc.simd : prefetch; prefetch!( rw, locality )( p ); 2. GCC: builtin_prefetch (const void *addr, ...) ¶ “This function is used to minimize cache-miss latency by moving data into a cache before it is accessed. You can insert calls to __builtin_prefetch into code for which you know addresses of data in memory that is likely to be accessed soon. If the target supports them, data prefetch instructions are generated. If the prefetch is done early enough before the access then the data will be in the cache by the time it is accessed. The value of addr is the address of the memory to prefetch. There are two optional arguments, rw and locality. The value of rw is a compile-time constant one or zero; one means that the prefetch is preparing for a write to the memory address and zero, the default, means that the prefetch is preparing for a read. The value locality must be a compile-time constant integer between zero and three. A value of zero means that the data has no temporal locality, so it need not be left in the cache after the access. A value of three means that the data has a high degree of temporal locality and should be left in all levels of cache possible. Values of one and two mean, respectively, a low or moderate degree of temporal locality. The default is three.” 3. declare void @llvm.prefetch(ptr , i32 , i32 , i32 4. Regarding llvm.prefetch() I found the following spec: “rw is the specifier determining if the fetch should be for a read (0) or write (1), and locality is a temporal locality specifier ranging from (0) - no locality, to (3) - extremely local keep in cache. The cache type specifies whether the prefetch is performed on the data (1) or instruction (0) cache. The rw, locality and cache type arguments must be constant integers.” 5. I also found this snippet https://dlang.org/phobos/core_builtins.html - which is great for the syntax of the call to the LDC builtin, but the call for GDC is no good as it lacks the parameters that I want. This D runtime routine might benefit from accepting all the parameters that GCC’s prefetch builtin takes. Many thanks in advance.
Windows API: GetUserName: Retrieve the name of the user associated with the current thread.
I'm sharing some code here. **It's not completely tested and might contain serious mistakes, repetitions, bad style and readabilty. But it seems to work.** Critique, improvements and feedback might help. Demonstration This code retrieves username of the current windows user using Windows API (Win32). ![img1](https://i.imgur.com/aNyyglu.png) **WindowsGetUserName.d** ``` import core.sys.windows.windows; import std.conv; import std.stdio; import std.range; pragma(lib, "advapi32.lib"); /** * Retrieves the currently logged-in user's name in a safe manner. * * This function first determines the required buffer size, allocates memory for the username, * and then retrieves the username. * * Returns: * - The username as a string if successful. * - An empty string if an error occurs. */ string getSafeUsername() @system { wchar[] userName; DWORD userNameSize = 0; // First, try GetUserNameW (Unicode version) if (!GetUserNameW(null, )) { int error = GetLastError(); if (error != ERROR_INSUFFICIENT_BUFFER) { // Failed for a reason other than an insufficient buffer return ""; } } // Allocate memory for userName scope(exit) userName.length = 0; // Ensure memory is released if an exception occurs userName.length = userNameSize; // Retrieve the user name by calling GetUserNameW if (GetUserNameW(userName.ptr, )) { // Successfully retrieved the user name, convert it to a string return to!string(userName); } // If GetUserNameW fails, try GetUserNameA (ANSI version) char[] userNameA; userNameSize = 0; if (!GetUserNameA(null, )) { int errorA = GetLastError(); if (errorA != ERROR_INSUFFICIENT_BUFFER) { // Failed for a reason other than an insufficient buffer return ""; } } // Allocate memory for userNameA scope(exit) userNameA.length = 0; // Ensure memory is released if an exception occurs userNameA.length = userNameSize; // Retrieve the user name by calling GetUserNameA if (GetUserNameA(userNameA.ptr, )) { // Successfully retrieved the user name using ANSI version, convert it to a string return to!string(userNameA); } // Both GetUserNameW and GetUserNameA failed, return an empty string return ""; } /** * The entry point of the application. */ void main() { string username = getSafeUsername(); if (!username.empty) { writeln("Logged-in user name: ", username); } else { writeln("Failed to retrieve the user name."); } } ``` Footnotes https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getusernamea https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getusernamew https://github.com/dlang/dmd/blob/master/druntime/src/core/sys/windows/winbase.d#L1903-L1904
Windows API: lld-link: error: undefined symbol: GetUserNameA
Today I've tried to use Windows API once again and encountered very time consuming case. It's been a long time since the last time I used Windows API. This time I've had an idea that it would be interesting to get thread associated username using Windows API. So after some time while trying to come up with something that might seemingly work. I've encountered this error: ### Error ``` C:\Users\Windows10\Desktop\interpreter>dmd WindowsGetUserName.d lld-link: error: undefined symbol: GetUserNameA referenced by WindowsGetUserName.obj:(_Dmain) Error: linker exited with status 1 ``` ### The Code ```D import std.stdio; import core.sys.windows.windows; import std.conv; void main() { char[256] userName; // Buffer to store the user name DWORD userNameSize = userName.length; // Size of the buffer // Call GetUserName to retrieve the user name if (GetUserNameA(userName.ptr, )) { // Successfully retrieved the user name writeln("Logged-in user name: ", to!string(userName[0 .. userNameSize])); } else { // Failed to retrieve the user name int error = GetLastError(); writeln("GetUserName failed with error code: ", error); } } ``` ### 1. Solution Remember to link **advapi32.lib** * `dmd WindowsGetUserName.d -Ladvapi32.lib` * `rdmd -Ladvapi32.lib WindowsGetUserName.d` ### 2. Solution Remember to include `pragma` into your source code and specify `advapi32.lib` ``` import std.stdio; import core.sys.windows.windows; import std.conv; pragma(lib, "advapi32.lib"); void main() { char[256] userName; // Buffer to store the user name DWORD userNameSize = userName.length; // Size of the buffer // Call GetUserName to retrieve the user name if (GetUserNameA(userName.ptr, )) { // Successfully retrieved the user name writeln("Logged-in user name: ", to!string(userName[0 .. userNameSize])); } else { // Failed to retrieve the user name int error = GetLastError(); writeln("GetUserName failed with error code: ", error); } } ```
Re: Mir-algorithm tutorial?
On Saturday, 19 August 2023 at 01:44:16 UTC, Kyle Ingraham wrote: On Friday, 18 August 2023 at 12:14:45 UTC, Ferhat Kurtulmuş wrote: I think the main problem is the mir libraries won't get updates since Ilya recently said that he was not an open source developer anymore. That’s unfortunate for D but hopefully beneficial for Ilya. Was it said somewhere publicly where I can read more on it? https://forum.dlang.org/post/u7r1i8$rn7$1...@digitalmars.com
DMD: Versioning compilation: generate Identifier for each compilation and writeln it.
I would like to display some identifier that is set after compilation and remains unchanged. This is to recognise and check if two binaries belong to the same compilation or it is a different compilation. I would place it into **version** command of my program. This is what I have now. **Compilation ID** is where I would like to show the identifier. ``` registerCommand("version", "Show version", { writeln("Compilation date: " ~ __DATE__ ~ " " ~ __TIME__ ~ "\n Compilation ID: "); }); ```