std.file and non-English filename in Windows
In Windows, exists, rename, copy will report file not exists when you input non-English filename, such as Chinese 中文.txt
Re: std.file and non-English filename in Windows
On Monday, 1 January 2018 at 12:33:27 UTC, John Chapman wrote: On Sunday, 31 December 2017 at 18:21:29 UTC, Domain wrote: In Windows, exists, rename, copy will report file not exists when you input non-English filename, such as Chinese 中文.txt Works for me. I created a file with the name "中文.txt" and std.file.exists returned true. Is your D source file saved in ASCII by any chance? Try saving it with a different encoding, such as UTF8. Yes, "中文.txt".exists return true. But when then filename read from stdin, it return false stdin .byLineCopy(No.keepTerminator) .each!((a) { writefln("%s --> %s", a, a.exists); }); dir *.txt /b | test.exe English.txt --> true 中文.txt --> false
Re: std.file and non-English filename in Windows
On Monday, 1 January 2018 at 16:13:06 UTC, Domain wrote: On Monday, 1 January 2018 at 12:33:27 UTC, John Chapman wrote: On Sunday, 31 December 2017 at 18:21:29 UTC, Domain wrote: In Windows, exists, rename, copy will report file not exists when you input non-English filename, such as Chinese 中文.txt Works for me. I created a file with the name "中文.txt" and std.file.exists returned true. Is your D source file saved in ASCII by any chance? Try saving it with a different encoding, such as UTF8. Yes, "中文.txt".exists return true. But when then filename read from stdin, it return false stdin .byLineCopy(No.keepTerminator) .each!((a) { writefln("%s --> %s", a, a.exists); }); dir *.txt /b | test.exe English.txt --> true 中文.txt --> false Problem solved! I change the properties of cmd from "Raster Fonts" to "Consolas" and all work well. But I don't know why.
No error message in DMD 2.078.2
module main; void main () { writeln("Hello"); } Of course, this won't compile, but error message is confused: C:\Git\hello\source>dmd app.d app.d(5): Error: object.Error@(0): Access Violation 0x0065445A 0x006548FE 0x0064DBD3 0x004B0B90 0x004B8A02 0x00594813 0x005797E2 0x77E40608 in RtlAllocateHeap 0x77E3EB5E in RtlAllocateHeap 0x77E2DD5A in RtlRandom 0x004E0F98 0x005B6D16 0x0047BFCA 0x005DD152
How to split a string to a 2D array
I want to convert a string like " a,b1, 23 " to a 2D array like: [["a", "b"], ["1", "2"], ["3", "" ]] auto html = " a,b1, 23 "; auto rows = html.strip.chomp("").split(""); string[][] data; rows.each!(a => data ~= a.split(",")); string[][] result = data.map!(a => a.padRight("", data[0].length).map!(b => b.strip)).array; but the result is not a string[][]: Error: cannot implicitly convert expression `array(map(data))` of type `MapResult!(__lambda2, Result)[]` to `string[][]`
Re: How to split a string to a 2D array
On Saturday, 24 February 2018 at 07:51:27 UTC, Domain wrote: I want to convert a string like " a,b1, 23 " to a 2D array like: [["a", "b"], ["1", "2"], ["3", "" ]] auto html = " a,b1, 23 "; auto rows = html.strip.chomp("").split(""); string[][] data; rows.each!(a => data ~= a.split(",")); string[][] result = data.map!(a => a.padRight("", data[0].length).map!(b => b.strip)).array; but the result is not a string[][]: Error: cannot implicitly convert expression `array(map(data))` of type `MapResult!(__lambda2, Result)[]` to `string[][]` And why this not compile: rows.each!(a => data ~= a.split(",").map!(b => b.strip).padRight("", 2)); Error: cannot deduce function from argument types !()(string[]), candidates are: C:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm\iteration.d(899): C:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm\iteration.d(934):
Re: How to split a string to a 2D array
On Saturday, 24 February 2018 at 08:59:46 UTC, Domain wrote: On Saturday, 24 February 2018 at 07:51:27 UTC, Domain wrote: [...] And why this not compile: rows.each!(a => data ~= a.split(",").map!(b => b.strip).padRight("", 2)); Error: cannot deduce function from argument types !()(string[]), candidates are: C:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm\iteration.d(899): C:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm\iteration.d(934): OK, this compile: rows.each!(a => data ~= a.split(",").map!(b => b.strip).padRight("", 2).array);
Why toUTF8 not accept wchar[] as argument?
wchar[10] buffer; toUTF8(buffer); Error: template `std.utf.toUTF8` cannot deduce function from argument types `!()(wchar[10])`, candidates are: /dlang/dmd/linux/bin64/../../src/phobos/std/utf.d(2713): `std.utf.toUTF8(S)(S s) if (isInputRange!S && !isInfinite!S && isSomeChar!(ElementEncodingType!S))` I know buffer.idup is OK. But why? That's very inconvenient.
Re: Why toUTF8 not accept wchar[] as argument?
On Tuesday, 3 April 2018 at 02:31:15 UTC, Uknown wrote: On Tuesday, 3 April 2018 at 02:24:08 UTC, Domain wrote: wchar[10] buffer; toUTF8(buffer); Error: template `std.utf.toUTF8` cannot deduce function from argument types `!()(wchar[10])`, candidates are: /dlang/dmd/linux/bin64/../../src/phobos/std/utf.d(2713): `std.utf.toUTF8(S)(S s) if (isInputRange!S && !isInfinite!S && isSomeChar!(ElementEncodingType!S))` I know buffer.idup is OK. But why? That's very inconvenient. What you need to do is slice your buffer. So your call will become like this: --- toUTF8(buffer[]); --- Now it will work as expected. I see. Maybe the error message could be improved.
Alias this and opDispatch override
The following code fail to compile: enum KeyMod : int { LCtrl = 1 << 0, RCtrl = 1 << 1, Ctrl = LCtrl | RCtrl, } struct Flags(E) { public: BitFlags!(E, Yes.unsafe) flags; alias flags this; bool opDispatch(string name)() const if (__traits(hasMember, E, name)) { enum e = __traits(getMember, E, name); return (mValue & e) != 0; } } Flags!KeyMod keys; keys.LCtrl = true; assert(keys.Ctrl); Error: no property LCtrl for type Flags!(KeyMod) Error: no property Ctrl for type Flags!(KeyMod)
Re: Alias this and opDispatch override
On Friday, 7 September 2018 at 02:22:58 UTC, Domain wrote: The following code fail to compile: enum KeyMod : int { LCtrl = 1 << 0, RCtrl = 1 << 1, Ctrl = LCtrl | RCtrl, } struct Flags(E) { public: BitFlags!(E, Yes.unsafe) flags; alias flags this; bool opDispatch(string name)() const if (__traits(hasMember, E, name)) { enum e = __traits(getMember, E, name); return (mValue & e) != 0; } } Flags!KeyMod keys; keys.LCtrl = true; assert(keys.Ctrl); Error: no property LCtrl for type Flags!(KeyMod) Error: no property Ctrl for type Flags!(KeyMod) Sorry. This works: struct Flags(E) { public: BitFlags!(E, Yes.unsafe) flags; alias flags this; bool opDispatch(string name)() const if (__traits(hasMember, E, name)) { enum e = __traits(getMember, E, name); return cast(int)(flags & e) != 0; } void opDispatch(string name)(bool set) if (__traits(hasMember, E, name)) { enum e = __traits(getMember, E, name); if (set) flags |= e; else flags &= ~e; } }
subsystem:windows and writeln
When I link the app with /subsystem:windows, and all writeln and writefln will cause a enforcement failed (stdio.d:2889). I think this is unacceptable.
Re: subsystem:windows and writeln
On Friday, 16 November 2018 at 17:46:20 UTC, Adam D. Ruppe wrote: On Friday, 16 November 2018 at 17:36:01 UTC, Domain wrote: I think this is unacceptable. Why? You are asking it to write to a file that doesn't exist... you probably shouldn't be doing that... But I cannot control the 3rd library!
How to get all modules in a package at CT?
I have a package named command, and many modules inside it, such as command.build, command.pack, command.help... I want to get all these modules at compile time so that I know what command is available.
Nested sub packages in dub
How to do that?
How can I build dynamic library with ldc in termux?
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: cannot find -lphobos2-ldc-shared /data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: cannot find -ldruntime-ldc-shared
Re: How can I build dynamic library with ldc in termux?
On Sunday, 3 March 2019 at 01:47:50 UTC, Domain wrote: /data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: cannot find -lphobos2-ldc-shared /data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: cannot find -ldruntime-ldc-shared Any dub config example? ~> dub build Dynamic libraries are not yet supported as dependencies - building as static library. Performing "debug" build using /data/data/com.termux/files/usr/bin/ldc2 for aarch64, arm_hardfloat. dll:so ~master: target for configuration "library" is up to date. dll ~master: building configuration "application"... /data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: cannot find -lphobos2-ldc-shared /data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: cannot find -ldruntime-ldc-shared clang-7: error: linker command failed with exit code 1 (use -v to see invocation) Error: /data/data/com.termux/files/usr/bin/gcc failed with status: 1 /data/data/com.termux/files/usr/bin/ldc2 failed with exit code 1.
Re: How can I build dynamic library with ldc in termux?
On Sunday, 3 March 2019 at 12:25:28 UTC, kinke wrote: On Sunday, 3 March 2019 at 01:47:50 UTC, Domain wrote: /data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: cannot find -lphobos2-ldc-shared /data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: cannot find -ldruntime-ldc-shared Looks like that package isn't set-up 100% correctly - there should be a `-link-defaultlib-shared=false` as default switch in the etc/ldc2.conf config file if the package doesn't contain shared druntime/Phobos. It seems already there: // default switches injected before all explicit comma> switches = [ "-defaultlib=phobos2-ldc,druntime-ldc", "-link-defaultlib-shared=false", ];
Re: How can I build dynamic library with ldc in termux?
On Sunday, 3 March 2019 at 01:51:49 UTC, Domain wrote: [...] Sorry, my mistake. I can build dynamic library now.
How to use readText to read utf16 file?
How to use readText to read utf16 file? Or other encoding file.
Re: How to use readText to read utf16 file?
On Tuesday, 17 November 2015 at 02:42:29 UTC, Adam D. Ruppe wrote: On Tuesday, 17 November 2015 at 02:40:14 UTC, Domain wrote: How to use readText to read utf16 file? readText!wstring("filename") should do it for utf16. It will return a wstring, which is utf-16. You can do utf32 with readText!dstring. The default, of course, is string, which is utf8. It doesn't support conversions or any other encoding. Thanks! But how to remove BOM? Slice the result myself?
Re: How to use readText to read utf16 file?
On Tuesday, 17 November 2015 at 03:12:47 UTC, Steven Schveighoffer wrote: On 11/16/15 10:00 PM, Adam D. Ruppe wrote: On Tuesday, 17 November 2015 at 02:50:44 UTC, Domain wrote: Thanks! But how to remove BOM? Slice the result myself? Yeah. Do something like if(result.length &&result[0] == bom) { result = result[1..$]; } and you'll have it. To be technically correct, you can do: if(!result.empty && result.front == bom) result.popFront(); This should work for all 3 types of strings. -Steve Thank you! Now another question: how to handle endianness?
Cannot build dfix, dcd with dub
I use the latest dmd. It seems dub fetch the wrong dependencies C:\Domain\d>dub build dfix --build=release Building package dfix in C:\Users\Domain\AppData\Roaming\dub\packages\dfix-0.3. 1\dfix\ Fetching experimental_allocator 2.70.0-b1 (getting selected version)... Fetching libdparse 0.3.0 (getting selected version)... Performing "release" build using dmd for x86. experimental_allocator 2.70.0-b1: building configuration "library"... ..\..\Users\ewanjma\AppData\Roaming\dub\packages\experimental_allocator-2.70.0-b 1\experimental_allocator\src\std\experimental\allocator\package.d(322,13): Error : std.experimental.allocator.common.Ternary at ..\..\Users\ewanjma\AppData\Roami ng\dub\packages\experimental_allocator-2.70.0-b1\experimental_allocator\src\std\ experimental\allocator\common.d(14,1) conflicts with std.typecons.Ternary at C:\ D\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(7658,1) ..\..\Users\ewanjma\AppData\Roaming\dub\packages\experimental_allocator-2.70.0-b 1\experimental_allocator\src\std\experimental\allocator\package.d(328,13): Error : std.experimental.allocator.common.Ternary at ..\..\Users\ewanjma\AppData\Roami ng\dub\packages\experimental_allocator-2.70.0-b1\experimental_allocator\src\std\ experimental\allocator\common.d(14,1) conflicts with std.typecons.Ternary at C:\ D\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(7658,1) ..\..\Users\ewanjma\AppData\Roaming\dub\packages\experimental_allocator-2.70.0-b 1\experimental_allocator\src\std\experimental\allocator\package.d(348,13): Error : std.experimental.allocator.common.Ternary at ..\..\Users\ewanjma\AppData\Roami ng\dub\packages\experimental_allocator-2.70.0-b1\experimental_allocator\src\std\ experimental\allocator\common.d(14,1) conflicts with std.typecons.Ternary at C:\ D\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(7658,1) dmd failed with exit code 1.
Re: make Pid constructor public
On Monday, 17 June 2013 at 22:38:47 UTC, Timothee Cour wrote: inside std.process it says: // Pids are only meant to be constructed inside this module, so we make the constructor private. However, this makes a number of useful functions from std.process useless unless the processes were created via one of std.process' functions. Can we make std.process.Pid.this(int pid) public? Use case: int pid=...; //parse pid from call to 'ps au' for example std.process.kill(pid); std.process.wait(pid); //etc I know this is an old post, but I need this feature! Any plan to make this happen?
Re: Debugging D applications from VS code with webfreak.debug
On Friday, 24 February 2017 at 13:19:53 UTC, FR wrote: On Friday, 24 February 2017 at 03:15:11 UTC, Jerry wrote: You can use the C++ plugin, which provides a debugger. Just make sure you aren't using optlink, I don't think it generates compatible files. Also you might need to use "-gc" which generates debug names to be in C format. https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools You might also need to enable breakpoints anywhere in VS code user setting file. Awesome! After finding the right combination of flags (-g and -m64 fed to dmd via dflags-dmd in my dub.json) this works quite nicely. Thanks a lot! Is there anywhere I can contribute this as documentation? I cannot debug my app with mago-mi. I click debug button, but nothing happen. I have installed cpptools, mago-mi, webfreak.debug, and I have tried vscode-dlang and code-d. My launch.json: { "version": "0.2.0", "configurations": [ { "name": "Debug", "type": "mago-mi", "request": "launch", "target": "${workspaceRoot}/bin/exp.exe", "cwd": "${workspaceRoot}", "preLaunchTask": "build" } ] }
How to debug in vscode with mago-mi?
Could anyone show me how to debug in vscode with mago-mi? I have installed vscode with Native Debug, SDLang. I have tried dlang-vscode and code-d. My tasks.json: { "version": "2.0.0", "command": "dub", "type": "shell", "presentation": { "echo": true, "reveal": "always", "focus": false, "panel": "shared" }, "tasks" : [ { "taskName": "build", "group": { "kind": "build", "isDefault": true }, "args": [], //Pattern match DMD error messages "problemMatcher": { "owner": "d", "fileLocation": ["relative", "${workspaceRoot}"], "pattern": { "regexp": "^(.*)\\((\\d+),(\\d+)\\):\\s+(Warning|Error):\\s+(.*)$", "file": 1, "line": 2, "column": 3, "severity": 4, "message": 5 } } } ] } And my launch.json: { "version": "0.2.0", "configurations": [ { "name": "Debug", "type": "mago-mi", "request": "launch", "target": "./bin/app.exe", "cwd": "${workspaceRoot}" } ] } I have placed mago-mi.exe in PATH. I can build app.exe successfully. But when I click the debug button, nothing happen.
Re: How to debug in vscode with mago-mi?
On Thursday, 20 July 2017 at 15:31:55 UTC, WebFreak001 wrote: On Monday, 17 July 2017 at 08:44:46 UTC, Domain wrote: Could anyone show me how to debug in vscode with mago-mi? I have installed vscode with Native Debug, SDLang. I have tried dlang-vscode and code-d. [...] Is the application actually being put in bin/app.exe? Also try a different debugger (the windows debugger from the C/C++ Extension by Microsoft which uses the visual studio debugger is quite good) Yes, I have visual studio installed. I can debug with VisualD. And I can debug with mago-mi from commandline, but not in vs code. When I click debug button, I can see the debug toolbar, but it will be gone in seconds. And no breakpoint hit. My source structure --| |--bin | |--app.exe | |--src | |--app.d | |--dub.json | |--.vscode | |--task.json | |--launch.json | |--.dub
Cannot find std.datetime when linking after upgrade to 2.075.0
After upgrade dmd to latest 2.075.0, my project no longer build: zero.lib(core_cde_4a4f.obj) : error LNK2001: unresolved external symbol _D3std8d atetime9LocalTime6opCallFNaNbNeZyC3std8datetime9LocalTime and many more. All about std.datetime.
Re: Cannot find std.datetime when linking after upgrade to 2.075.0
On Friday, 21 July 2017 at 19:05:00 UTC, Jonathan M Davis wrote: On Friday, July 21, 2017 15:33:45 Domain via Digitalmars-d-learn wrote: After upgrade dmd to latest 2.075.0, my project no longer build: zero.lib(core_cde_4a4f.obj) : error LNK2001: unresolved external symbol _D3std8d atetime9LocalTime6opCallFNaNbNeZyC3std8datetime9LocalTime and many more. All about std.datetime. Then it sounds like you need to make sure that you rebuild your project and all of its dependencies (which you should be doing with any compiler upgrade anyway, since they're not ABI compatible). Your code should work just fine with std.datetime and 2.075.0 without any changes, but it will need to be recompiled. https://dlang.org/changelog/2.075.0.html#split-std-datetime - Jonathan M Davis I have tried dub build --force and rebuild solution in VisualD, but nothing changed. Maybe I have to remove the lib manually.
Re: Cannot find std.datetime when linking after upgrade to 2.075.0
On Friday, 21 July 2017 at 19:05:00 UTC, Jonathan M Davis wrote: On Friday, July 21, 2017 15:33:45 Domain via Digitalmars-d-learn wrote: After upgrade dmd to latest 2.075.0, my project no longer build: zero.lib(core_cde_4a4f.obj) : error LNK2001: unresolved external symbol _D3std8d atetime9LocalTime6opCallFNaNbNeZyC3std8datetime9LocalTime and many more. All about std.datetime. Then it sounds like you need to make sure that you rebuild your project and all of its dependencies (which you should be doing with any compiler upgrade anyway, since they're not ABI compatible). Your code should work just fine with std.datetime and 2.075.0 without any changes, but it will need to be recompiled. https://dlang.org/changelog/2.075.0.html#split-std-datetime - Jonathan M Davis I have deleted all dependencies and rebuild everything, but still get those errors! C:\Domain\d\game>dub build zero:plugin1 --arch=x86_64 --force Building package zero:plugin1 in C:\Domain\d\game\ Fetching pegged 0.4.2 (getting selected version)... Fetching msgpack-d 1.0.0-beta.6 (getting selected version)... WARNING: A deprecated branch based version specification is used for the depende ncy zero. Please use numbered versions instead. Also note that you can still use the dub.selections.json file to override a certain dependency to use a branch i nstead. Performing "debug" build using dmd for x86_64. msgpack-d 1.0.0-beta.6: building configuration "library"... pegged 0.4.2: building configuration "default"... zero ~master: building configuration "library"... zero:plugin1 ~master: building configuration "library"... Linking... src\plugins\plugin1\dll.def(4) : warning LNK4017: EXETYPE statement not supporte d for the target platform; ignored Creating library .dub\build\library-debug-windows-x86_64-dmd_2075-1F996E49B53 F3A00022177DB92F8CC26\PlugIn1.lib and object .dub\build\library-debug-windows-x8 6_64-dmd_2075-1F996E49B53F3A00022177DB92F8CC26\PlugIn1.exp PlugIn1.obj : error LNK2001: unresolved external symbol _D3std8datetime7SysTime8 toStringMxFNbNfZAya PlugIn1.obj : error LNK2001: unresolved external symbol _D3std8datetime7SysTime8 __xopCmpFKxS3std8datetime7SysTimeKxS3std8datetime7SysTimeZi PlugIn1.obj : error LNK2001: unresolved external symbol _D3std8datetime7SysTime8 opEqualsMxFNaNbNfKxS3std8datetime7SysTimeZb zero.lib(formattedLogger_aa3_d61.obj) : error LNK2001: unresolved external symbo l _D3std8datetime7SysTime8opEqualsMxFNaNbNfKxS3std8datetime7SysTimeZb PlugIn1.obj : error LNK2001: unresolved external symbol _D3std8datetime7SysTime6 toHashMxFNaNbNiNfZm zero.lib(formattedFileLogger_aa2_786.obj) : error LNK2001: unresolved external s ymbol _D3std12experimental6logger4core6Logger11beginLogMsgMFNfAyaiAyaAyaAyaE3std 12experimental6logger4core8LogLevelS3std11concurrency3TidS3std8datetime7SysTimeC 3std12experimental6logger4core6LoggerZv zero.lib(formattedLogger_aa3_d61.obj) : error LNK2001: unresolved external symbo l _D3std12experimental6logger4core6Logger11beginLogMsgMFNfAyaiAyaAyaAyaE3std12ex perimental6logger4core8LogLevelS3std11concurrency3TidS3std8datetime7SysTimeC3std 12experimental6logger4core6LoggerZv zero.lib(formattedLogger_aa3_d61.obj) : error LNK2019: unresolved external symbo l _D3std8datetime7SysTime8fracSecsMxFNbNdNfZS4core4time8Duration referenced in f unction _D4zero6logger15formattedLogger57__T15FormattedLoggerTS3std5stdio4File17 LockingTextWriterZ15FormattedLogger12LogFormatter8toStringMFMDFAxaZvS3std6format 18__T10FormatSpecTaZ10FormatSpecZv zero.lib(formattedLogger_aa3_d61.obj) : error LNK2019: unresolved external symbo l _D3std8datetime7SysTime14toISOExtStringMxFNbNfZAya referenced in function _D4z ero6logger15formattedLogger57__T15FormattedLoggerTS3std5stdio4File17LockingTextW riterZ15FormattedLogger12LogFormatter8toStringMFMDFAxaZvS3std6format18__T10Forma tSpecTaZ10FormatSpecZv .dub\build\library-debug-windows-x86_64-dmd_2075-1F996E49B53F3A00022177DB92F8CC2 6\PlugIn1.dll : fatal error LNK1120: 7 unresolved externals Error: linker exited with status 1120 dmd failed with exit code 1120.
Re: Cannot find std.datetime when linking after upgrade to 2.075.0
On Friday, 21 July 2017 at 19:05:00 UTC, Jonathan M Davis wrote: On Friday, July 21, 2017 15:33:45 Domain via Digitalmars-d-learn wrote: After upgrade dmd to latest 2.075.0, my project no longer build: zero.lib(core_cde_4a4f.obj) : error LNK2001: unresolved external symbol _D3std8d atetime9LocalTime6opCallFNaNbNeZyC3std8datetime9LocalTime and many more. All about std.datetime. Then it sounds like you need to make sure that you rebuild your project and all of its dependencies (which you should be doing with any compiler upgrade anyway, since they're not ABI compatible). Your code should work just fine with std.datetime and 2.075.0 without any changes, but it will need to be recompiled. https://dlang.org/changelog/2.075.0.html#split-std-datetime - Jonathan M Davis Never mind. It looks like the installation files are corrupted. I remove the entire dmd, download and install again, everything work fine now.
mixin template, extern(C/Windows) and mangled name
I known there is a bug with extern(C) in mixin template: https://issues.dlang.org/show_bug.cgi?id=12575 And I can see SimpleDllMain in core.sys.windows.dll, the mangled name is correct: DllMain But my mixin template has wrong mangled name: mixin template GetMetaData() { extern(Windows) MetaData GetMetaData() { return MetaData(); } } mixin GetMetaData; I can see the mangled name is: _D3app8__mixin911GetMetaDataWZS4zero7plugins8metadata8MetaData
Re: mixin template, extern(C/Windows) and mangled name
On Tuesday, 1 August 2017 at 03:30:08 UTC, Adam D. Ruppe wrote: On Tuesday, 1 August 2017 at 03:08:30 UTC, Domain wrote: And I can see SimpleDllMain in core.sys.windows.dll, the mangled name is correct: DllMain main, DllMain, and WinMain are special cased... for yours, I think you'll have to hack it with pragma(mangle) mixin template GetMetaData() { pragma(mangle, "GetMetaData") // or whatever maybe @0 ? extern(Windows) MetaData GetMetaData() { return MetaData(); } } mixin GetMetaData; I think. Thanks. Anyone known any plan for issue 12575? It has been 3 years, it looks like not that hard to fix.
sharedLog between dll
I want to redirect the sharedLog to my logger in one dll, and all dlls will use the new one. What should I do? sharedLog = new MyLogger(); // this will not change the logger in other dll
Re: sharedLog between dll
On Tuesday, 1 August 2017 at 09:06:39 UTC, rikki cattermole wrote: On 01/08/2017 9:28 AM, Domain wrote: I want to redirect the sharedLog to my logger in one dll, and all dlls will use the new one. What should I do? sharedLog = new MyLogger(); // this will not change the logger in other dll You said the magic phrase, DLL. Can't share e.g. classes between dll/host[0]. [0] https://issues.dlang.org/show_bug.cgi?id=4071 That issue is reported 7 years ago! I think DLL support should be a basic feature. And I think the core team spend too little time on those features which will block the usage of D in the real world. I have to reconsider using C++ instead.
How to overload with enum type?
void f(int i) { writeln("i"); } void f(E)(E e) if (is(E == enum)) { writeln("e"); } enum E { A } E e = E.A; f(e);// output i How can I overload with enum type?
Re: How to overload with enum type?
On Sunday, 15 October 2017 at 08:47:42 UTC, Domain wrote: void f(int i) { writeln("i"); } void f(E)(E e) if (is(E == enum)) { writeln("e"); } enum E { A } E e = E.A; f(e);// output i How can I overload with enum type? I know I can do that with this: void f(T)(T i) if (is(T == int)) { writeln("i"); } But that looks strange.
Re: debugging in vs code on Windows
On Sunday, 15 October 2017 at 13:54:49 UTC, Dmitry wrote: On Friday, 13 October 2017 at 12:55:09 UTC, piotrklos wrote: Has anyone been able to debug in VS code on Windows? What am I doing wrong? Yep, it work for me. How do you start debugging? I noticed that the bottom button (small bug) at status bar doesn't work for me. But when I use Debug → Start Debugging (F5), it works. Can you share your tasks.json and launch.json?
Re: debugging in vs code on Windows
On Tuesday, 17 October 2017 at 03:10:52 UTC, Dmitry wrote: On Tuesday, 17 October 2017 at 02:32:49 UTC, Domain wrote: Can you share your tasks.json and launch.json? tasks.json - I don't have this file. launch.json: { "version": "0.2.0", "configurations": [ { "name": "(Windows) Launch", "type": "cppvsdbg", "request": "launch", "program": "${workspaceRoot}\\parser.exe", "args": [], "stopAtEntry": false, "cwd": "${workspaceRoot}", "environment": [], "externalConsole": true } ] } Also I have changed preferences: "debug.allowBreakpointsEverywhere": true, Status bar: x86_64 debug dmd Thank you very much! I used to use "mago-mi" type configuration, and never succeed.
Re: debugging in vs code on Windows
On Tuesday, 17 October 2017 at 08:43:33 UTC, Domain wrote: On Tuesday, 17 October 2017 at 03:10:52 UTC, Dmitry wrote: On Tuesday, 17 October 2017 at 02:32:49 UTC, Domain wrote: Can you share your tasks.json and launch.json? tasks.json - I don't have this file. launch.json: { "version": "0.2.0", "configurations": [ { "name": "(Windows) Launch", "type": "cppvsdbg", "request": "launch", "program": "${workspaceRoot}\\parser.exe", "args": [], "stopAtEntry": false, "cwd": "${workspaceRoot}", "environment": [], "externalConsole": true } ] } Also I have changed preferences: "debug.allowBreakpointsEverywhere": true, Status bar: x86_64 debug dmd Thank you very much! I used to use "mago-mi" type configuration, and never succeed. This is my tasks.json: { // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "2.0.0", // Run the dub command to do a build or test "type": "shell", "command": "dub", "presentation": { "echo": true, "reveal": "always", "focus": false, "panel": "shared" }, "tasks": [ { "taskName": "build", "args": [ "--arch=x86_mscoff", "--build=debug" ], "group": { "kind": "build", "isDefault": true }, "problemMatcher": { "owner": "d", "fileLocation": [ "relative", "${workspaceRoot}" ], "pattern": { "regexp": "^([^(]*)\\((\\d+),\\s*(\\d+)\\):\\s*(Warning|Error):\\s+(.*)$", "file": 1, "line": 2, "column": 3, "severity": 4, "message": 5 } } }, { "taskName": "test", "group": "test", "problemMatcher": { "owner": "d", "fileLocation": [ "relative", "${workspaceRoot}" ], "pattern": { "regexp": "^([^(]*)\\((\\d+),\\s*(\\d+)\\):\\s*(Warning|Error):\\s+(.*)$", "file": 1, "line": 2, "column": 3, "severity": 4, "message": 5 } } } ] } And this is my launch.json: { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "Debug", "type": "cppvsdbg", "request": "launch", "program": "${workspaceRoot}/app.exe", "args": [], "stopAtEntry": false, "cwd": "${workspaceRoot}", "environment": [], "externalConsole": true, "preLaunchTask": "build" } ] }
How to find all modules in a package?
I want to find out all public functions in all modules in a package. Can I do that at compile time?
Re: How to find all modules in a package?
On Wednesday, 3 August 2022 at 12:27:32 UTC, frame wrote: On Wednesday, 3 August 2022 at 03:36:55 UTC, Domain wrote: I want to find out all public functions in all modules in a package. Can I do that at compile time? You can do something like that: ```d static foreach (sym; __traits(allMembers, mixin("std.string"))) { pragma(msg, sym.stringof); } ``` Then you would have to check if `sym` is a template or function or something else. This give me all symbols in the package.d file.
How long will DUB update a package from github release?
The project [Lumars](https://code.dlang.org/packages/lumars) has released a new version 10 days ago in [github](https://github.com/BradleyChatha/lumars). But still unavailable in DUB.
Any full feature xml library available?
I need a xml library which support document entity or xinclude. The xml may like this: ]> http://www.w3.org/2001/XInclude";> &data;
Re: Any full feature xml library available?
On Wednesday, 1 May 2019 at 13:57:04 UTC, bachmeier wrote: On Wednesday, 1 May 2019 at 13:54:08 UTC, Domain wrote: I need a xml library which support document entity or xinclude. The xml may like this: ]> http://www.w3.org/2001/XInclude";> &data; Have you looked at this? https://github.com/jmdavis/dxml Yes, but I don't think dxml support these features.
Re: Any full feature xml library available?
On Friday, 3 May 2019 at 21:07:29 UTC, H. S. Teoh wrote: On Fri, May 03, 2019 at 09:56:56PM +0100, Russel Winder via Digitalmars-d-learn wrote: On Thu, 2019-05-02 at 09:28 -0700, H. S. Teoh via Digitalmars-d-learn wrote: > On Thu, May 02, 2019 at 05:23:29PM +0100, Russel Winder via > Digitalmars-d-learn wrote: > [...] > > [...] > [...] > > No particular reason, except nobody has taken up the task > yet. Would you? If I were interested in XML processing yes I would. However, just at the moment I am doing things with MPEG-TS and gstreamer-rs. I may investigate the analogue for GstreamerD. On the other hand there are enough people moaning about std.xml and the general lack of quality, high performance D support for XML that there is clearly a lot of people who should be interested in creating a D binding to libxml2. [...] The problem is that while there is no shortage of complaints about XML support in D, there is a great dearth of people actually willing to *do* something about it. At least Jonathan wrote dxml, which arguably would meet the need in most cases. So there's that. But if somebody wants entity references and other similar things, the only recourse would appear to be to wrap libxml2. Given D's aptitude at interfacing with C, this should be much simpler than writing dxml. It just needs someone to sit down and *do* it. T I am trying to port libxml++ to D. I use dstep to generate the binding to libxml2, and then porting c++ to D. But I don't have much time, and there are some failures with dstep. I don't have a computer at home, so I must use termux to coding. I hope someone can continue to maintaining the android port of ldc.
Another bug in function overloading?
module test; public interface I { void foo(); void foo(int); } public abstract class A : I { public void bar() { foo(); } public void foo(int i) { } } public class C : A { public void foo() { } public void bar2() { foo(1); } } Error: function test.A.foo (int i) is not callable using argument types () Error: function test.C.foo () is not callable using argument types (int)