Re: Passing pointer to extern(C++) templated function

2020-10-13 Thread kinke via Digitalmars-d-learn
On Wednesday, 14 October 2020 at 00:25:56 UTC, Jamie wrote: Happy to file a bug, but if it was a bug in the mangler wouldn't both C++ and D get the same result? Assuming D uses the same mangler for the extern(C++) stuff. Bug in the D frontend implementation of Itanium C++ mangling.

Re: Passing pointer to extern(C++) templated function

2020-10-13 Thread kinke via Digitalmars-d-learn
On Tuesday, 13 October 2020 at 09:23:48 UTC, Jamie wrote: It appears that func3 and func4 take on different types depending on other variables being present? Is this expected? Nope, it's a bug in the Itanium C++ mangler, please file a bug. MSVC++ mangling seems fine, after fixing the D

Re: Link Time Optimization Bitcode File Format

2020-10-06 Thread kinke via Digitalmars-d-learn
On Tuesday, 6 October 2020 at 16:46:28 UTC, Severin Teona wrote: Also, when I try to link the druntime with the application I want to write on the microcontroller, there are some link errors due to the file format. This happens when you link manually, not through LDC. When running LDC with

Re: Trying to create a trivial 64 bit D Lang DLL on a Windows 10 machine and cant get past linking.

2020-10-01 Thread kinke via Digitalmars-d-learn
On Thursday, 1 October 2020 at 20:03:19 UTC, WhatMeWorry wrote: Yes, but shouldn't the /NOENTRY option take care of that. Say, I just want to make a DLL of simple functions. Your little example has 2 problems, the first being an incompatible extern(D) ex/import (mydll.myAddSeven vs.

Re: How to implement fastcall ?

2020-09-23 Thread kinke via Digitalmars-d-learn
On Wednesday, 23 September 2020 at 19:50:13 UTC, Denis Feklushkin wrote: On Monday, 21 September 2020 at 11:14:06 UTC, Виталий Фадеев wrote: How to implement fastcall ? ( stdcall is calling convention for pass function arguments via registers ) Hypothesis: it is possible what LLVM + Link

Re: Trouble with Android and arsd.jni

2020-09-10 Thread kinke via Digitalmars-d-learn
On Thursday, 10 September 2020 at 13:14:00 UTC, burt wrote: However, the app is still crashing when I load it, and there appears to be an issue in Runtime.initialize(), which is called from JNI_OnLoad(), which is defined in arsd.jni. The debugger tells me that it was calling

Re: Trouble with Android and arsd.jni

2020-09-10 Thread kinke via Digitalmars-d-learn
On Thursday, 10 September 2020 at 11:16:55 UTC, burt wrote: However, I am getting linker errors, telling me that _tlsend, _tlsstart and __bss_end__ are missing. Perhaps you happen to use some stale artifacts? These magic symbols aren't used anymore in druntime since LDC v1.21, and not

Re: GC.LDC2 on Android

2020-09-08 Thread kinke via Digitalmars-d-learn
On Tuesday, 8 September 2020 at 12:47:11 UTC, Danny Arends wrote: How can I figure out which linker is used ? When performing a dub build, it just mentions that ldc2 is used for linking You can add -v as dub 'linker' flag, that will make LDC show the actual cmdline. LDC v1.23 defaults to

Re: GC.LDC2 on Android

2020-09-08 Thread kinke via Digitalmars-d-learn
On Tuesday, 8 September 2020 at 11:17:45 UTC, Danny Arends wrote: Does anyone have any experience with using D on android, and using the garbage collector ??? I've never run anything on Android myself, but I've gotten good feedback on AArch64 at least. Make sure to use a recent LDC, and

Re: Building LDC runtime for a microcontroller

2020-09-07 Thread kinke via Digitalmars-d-learn
On Monday, 7 September 2020 at 15:23:28 UTC, Severin Teona wrote: CMake Error at /snap/cmake/549/share/cmake-3.18/Modules/CMakeTestCCompiler.cmake:66 (message): This is apparently a non-LDC specific issue, a default CMake C compiler sanity check fails. When looking at that file, you'll see

Re: How to define delegate what returns ref?

2020-08-28 Thread kinke via Digitalmars-d-learn
On Friday, 28 August 2020 at 11:46:15 UTC, Oleg B wrote: How to do this more clearly? alias Dg = ref int delegate(); Dg foo;

Re: BetterC + WASM Update

2020-08-19 Thread kinke via Digitalmars-d-learn
On Wednesday, 19 August 2020 at 21:24:23 UTC, Mike Brown wrote: I have done some tests, and it appears that classes are supported (LDC 1.22.0)? extern(C++) classes are supported by -betterC. With LDC, D classes are supported to some extent too since v1.11, but this requires a custom object.d

Re: LDC cross-module-inlining

2020-08-10 Thread kinke via Digitalmars-d-learn
On Monday, 10 August 2020 at 11:11:57 UTC, Per Nordlöw wrote: Are the official LDC-releases builtin with or without LTO? Most of them are, but not sure why that matters here (the gain is almost negligible and mainly interesting for the C++ parts - as all D files are compiled to a single

Re: __vector(ubyte[32]) misalignment

2020-08-09 Thread kinke via Digitalmars-d-learn
On Sunday, 9 August 2020 at 01:03:51 UTC, Bruce Carneal wrote: Is sub .alignof alignment expected here? IOW, do I have to manually manage memory if I want alignments above 16? IIRC, yes when using the GC, as that only guarantees 16-bytes alignment. Static arrays on the stack should be

Re: Forcing inline functions (again) - groan

2020-07-15 Thread kinke via Digitalmars-d-learn
On Wednesday, 15 July 2020 at 13:38:34 UTC, Cecil Ward wrote: I recently noticed pragma(inline, true) which looks extremely useful. A couple of questions : 1. Is this cross-compiler compatible? Works for LDC and DMD, not sure about GDC, but if it doesn't support it, it's definitely on

Re: Choosing a non-default linker for dmd (via dub)

2020-07-15 Thread kinke via Digitalmars-d-learn
On Wednesday, 15 July 2020 at 11:38:47 UTC, Jacob Carlborg wrote: There's an environment variable "CC" that can be used to select which C compiler is used. Is there any equivalence for selecting the linker, "LD" perhaps? You normally just add -fuse-ld=gold to the C compiler cmdline, e.g.,

Re: BetterC Bug? Intended Behavior? Asking Here As Unsure

2020-07-06 Thread kinke via Digitalmars-d-learn
On Monday, 6 July 2020 at 22:02:37 UTC, Kayomn wrote: On Monday, 6 July 2020 at 21:09:57 UTC, kinke wrote: Similar case here; the 'varargs' end up in a GC-allocated array. I've recently changed `scope` slice params, so that array literal arguments are allocated on the caller's stack instead;

Re: BetterC Bug? Intended Behavior? Asking Here As Unsure

2020-07-06 Thread kinke via Digitalmars-d-learn
On Monday, 6 July 2020 at 20:25:11 UTC, Kayomn wrote: Though, admittedly I'm kind of used to seeing this error message since it appears any time you try and do something that relies on type info in betterC, intentionally or not. A notable example is forgetting to supply an arrange length when

Re: Catching OS Exceptions in Windows using LDC

2020-07-04 Thread kinke via Digitalmars-d-learn
On Saturday, 4 July 2020 at 12:59:03 UTC, Adam D. Ruppe wrote: For whatever reason, dmd 64 bit and ldc decided to do their own thing instead of following the Windows standard and thus have no interop with OS exceptions. For LDC, we don't do 'our own thing', but use MSVC++ EH, which allows to

Re: Generating struct .init at run time?

2020-07-02 Thread kinke via Digitalmars-d-learn
On Thursday, 2 July 2020 at 16:51:52 UTC, kinke wrote: `= void` for members doesn't work and, I dare say, not work anytime soon if ever. I've quickly checked; `= void` for members has initialize-with-zeros semantics too, so with LDC, it's equivalent to `= 0` but applicable to user-defined

Re: Generating struct .init at run time?

2020-07-02 Thread kinke via Digitalmars-d-learn
On Thursday, 2 July 2020 at 15:20:23 UTC, Ali Çehreli wrote: According to its date, it was written when I was working for Weka. Apparently, ldc took care of it for them after all. If so, then without them posting any issue beforehand or giving any feedback afterwards. > For recent LDC

Re: Generating struct .init at run time?

2020-07-02 Thread kinke via Digitalmars-d-learn
On Thursday, 2 July 2020 at 07:51:29 UTC, Ali Çehreli wrote: Of course, the solution is to define members with '= void' Since when? https://issues.dlang.org/show_bug.cgi?id=11331 and your https://issues.dlang.org/show_bug.cgi?id=16956 are still open. For recent LDC versions, the 'solution'

Re: Linking D with C structs

2020-06-29 Thread kinke via Digitalmars-d-learn
On Monday, 29 June 2020 at 06:29:38 UTC, Anthony wrote: What does "__initZ" refer to? Does this refer to automatic initialization like "this()"? Almost, it's the static initializer for that struct, which is omitted because you apparently don't compile/link the module containing the struct

Re: Garbage collection

2020-06-27 Thread kinke via Digitalmars-d-learn
On Saturday, 27 June 2020 at 15:27:34 UTC, Stanislav Blinov wrote: On Saturday, 27 June 2020 at 14:12:09 UTC, kinke wrote: Note that I explicitly clear the `str` slice before GC.collect(), so that the stack shouldn't contain any refs to the fat string anymore. Hrm... What happens if you

Re: Garbage collection

2020-06-27 Thread kinke via Digitalmars-d-learn
=> https://issues.dlang.org/show_bug.cgi?id=20983

Re: Garbage collection

2020-06-27 Thread kinke via Digitalmars-d-learn
On Saturday, 27 June 2020 at 10:08:15 UTC, James Gray wrote: have run into a memory leak Something seems really off indeed. I've run this on Win64 with DMD (2.092) and LDC (1.22), without any extra cmdline options: - import core.memory; import core.stdc.stdio; import std.range; import

Re: figure out where a particular template function is located

2020-06-24 Thread kinke via Digitalmars-d-learn
On Wednesday, 24 June 2020 at 21:05:12 UTC, Steven Schveighoffer wrote: I have a hard time believing that there's no way to do this! This would IMO be the job of the IDE. E.g., Visual D might be able to jump to the template declaration.

Re: figure out where a particular template function is located

2020-06-24 Thread kinke via Digitalmars-d-learn
On Wednesday, 24 June 2020 at 20:28:24 UTC, Steven Schveighoffer wrote: Is there a way to figure this out from the call? Another option would be running LDC with -vv for verbose codegen (be warned, lots and lots ouf output); we have fully qualified names in there.

Re: real.mant_dig on windows?

2020-06-23 Thread kinke via Digitalmars-d-learn
On Tuesday, 23 June 2020 at 02:56:36 UTC, 9il wrote: Should it always be 53? or it can be 64, when? Thank you For LDC, it's 53 (and .sizeof == 8) for MSVC targets, but 64 (x87) for MinGW, reflecting the accompanying C runtime's `long double`. [And IIRC, MS disallows any x87 usage in kernel

Re: called copy constructor in foreach with ref on Range

2020-06-22 Thread kinke via Digitalmars-d-learn
On Monday, 22 June 2020 at 20:51:37 UTC, Jonathan M Davis wrote: [...] That's why I put the struct in parantheses. Moving a class ref makes hardly any sense, but I've also never written a *class* to represent a range. Moving is the no-brainer solution for transferring ownership of struct

Re: how to skip the next (n) item & continue from (n+1) with a range ? e.g. in File(fn).byLine();

2020-06-22 Thread kinke via Digitalmars-d-learn
If you are referring to the next line, not the next n lines, that's a simple `continue;` statement.

Re: how to skip the next (n) item & continue from (n+1) with a range ? e.g. in File(fn).byLine();

2020-06-22 Thread kinke via Digitalmars-d-learn
On Monday, 22 June 2020 at 20:02:22 UTC, kinke wrote: If you are referring to the next line, not the next n lines, that's a simple `continue;` statement. [Please discard, that'd obviously be skipping the *current* line.]

Re: How to correctly integrate D library to Swift/Obj-C mobile project?

2020-06-22 Thread kinke via Digitalmars-d-learn
On Monday, 22 June 2020 at 19:41:22 UTC, Vlad wrote: Usually, when you connect c++/c, you have header files so you can call functions from Objective-C/swift code. We need something similar. There's a pretty recent -HC switch to generate C++ headers from `extern(C++)` declarations. Not sure

Re: called copy constructor in foreach with ref on Range

2020-06-22 Thread kinke via Digitalmars-d-learn
On Monday, 22 June 2020 at 19:03:44 UTC, Jonathan M Davis wrote: in practice, that means that generic code cannot use a range once it's been copied Translating to a simple rule-of-thumb: never copy a (struct) range, always move.

Re: called copy constructor in foreach with ref on Range

2020-06-22 Thread kinke via Digitalmars-d-learn
On Monday, 22 June 2020 at 16:25:11 UTC, Jonathan M Davis wrote: The reason that foreach copies the range is simply due to how the code is lowered. e.g. foreach(e; range) { } essentially becomes for(auto r = range; !r.empty; r.popFront()) { auto e = r.front; }

Re: called copy constructor in foreach with ref on Range

2020-06-21 Thread kinke via Digitalmars-d-learn
A foreach over a custom range makes an initial copy, so that the original range is still usable after the foreach (not empty).

Re: Arduino and MCU Support

2020-06-19 Thread kinke via Digitalmars-d-learn
On Friday, 19 June 2020 at 14:14:07 UTC, frasdoge wrote: though the -mcpu does not have any AVR options out-of-the-box as you mentioned. I guess you mean `ldc2 -mcpu=help` doesn't list any AVR CPUs. Use `ldc2 -mtriple=avr -mcpu=help`.

Re: Arduino and MCU Support

2020-06-19 Thread kinke via Digitalmars-d-learn
On Friday, 19 June 2020 at 14:14:07 UTC, frasdoge wrote: I'm having a bit of trouble understanding how to actually get started even with those links. I've installed the latest LDC and LLVM releases for Windows, though the -mcpu does not have any AVR options out-of-the-box as you mentioned.

Re: Arduino and MCU Support

2020-06-19 Thread kinke via Digitalmars-d-learn
On Friday, 19 June 2020 at 11:57:01 UTC, frasdoge wrote: I am looking to use D for microcontroller programming due to its benefits over C in workflow and general language features. I was wondering what the current state of this is, especially with regards to AVR. An example of the MCUs I

Re: Windows + LDC/DMD installation nightmare when changing VS versions

2020-06-12 Thread kinke via Digitalmars-d-learn
On Friday, 12 June 2020 at 15:21:12 UTC, Guillaume Piolat wrote: Any idea what could be causing this? Mentioning at least the used LDC version would be helpful; especially since the MSVC detection was completely overhauled with the v1.22 betas (and I think the previous

Re: how to achieve C's Token Pasting (##) Operator to generate variable name in D?

2020-05-30 Thread kinke via Digitalmars-d-learn
Using a mixin: string f(string x) { return "_" ~ x; } int main() { mixin("int "~f("x")~" = 3;"); return _x; }

Re: m32mscoff with lld-link causes SEH errors

2020-05-26 Thread kinke via Digitalmars-d-learn
On Monday, 25 May 2020 at 01:32:58 UTC, Daniel C wrote: Is lld-link only for 64-bit compiles (-m64 is the only one that gives no errors) Nope, but SafeSEH is a 32-bit-only feature. DMD doesn't emit SafeSEH compatible object files, and LLD seems to have a different default setting in that

Re: ModuleInfo and -fno-moduleinfo option

2020-05-26 Thread kinke via Digitalmars-d-learn
ModuleInfos are essential for the module ctors and dtors (of used modules) to be run, incl. a dependency tree defining their order of execution. They're also needed for running the unittests.

Re: large Windows mingw64 project in C99 --- need ABI compatible D compiler

2020-05-20 Thread kinke via Digitalmars-d-learn
On Wednesday, 20 May 2020 at 23:08:53 UTC, IGotD- wrote: When you mention the ABI, is there something particular you have in mind or just in general? The ABI for MinGW targets in general. - Judging by https://forum.dlang.org/post/anfwqjjsteeyelbdh...@forum.dlang.org, you apparently use a very

Re: large Windows mingw64 project in C99 --- need ABI compatible D compiler

2020-05-20 Thread kinke via Digitalmars-d-learn
On Wednesday, 20 May 2020 at 20:45:26 UTC, NonNull wrote: [...] so I will likely go with ldc2 with the option you suggested and see how it goes. Thanks again! You're welcome. If you do come across an ABI issue, make sure to file an LDC issue. While I have no interest in MinGW, I want at

Re: large Windows mingw64 project in C99 --- need ABI compatible D compiler

2020-05-20 Thread kinke via Digitalmars-d-learn
On Wednesday, 20 May 2020 at 18:53:01 UTC, NonNull wrote: Which D compiler should be used to be ABI compatible with mingw32? And which to be ABI compatible with mingw64? The natural choice for coupling mingw[64]-gcc would be GDC. Especially wrt. ABI, gdc apparently doesn't have to do much by

Re: After compiling Hello World with DMD Compiler, .EXE file takes 1-3 seconds to run for the first time

2020-05-18 Thread kinke via Digitalmars-d-learn
On Monday, 18 May 2020 at 15:49:06 UTC, Adam D. Ruppe wrote: It sees D programs as unusual and gives them additional scrutiny... Is that really the case for all D programs on Windows, or just those built with -m32 and thus using the exotic DigitalMars C runtime?

Re: Detecting performance pitfall in array access

2020-05-17 Thread kinke via Digitalmars-d-learn
On Sunday, 17 May 2020 at 11:39:30 UTC, kinke wrote: DMD v2.091: * dmd -m64 -O -release -boundscheck=off -run ..\speed.d aa bbc: ~11 μs I forgot `-inline` for DMD; that reduces the speed, yielding ~16 μs.

Re: Detecting performance pitfall in array access

2020-05-17 Thread kinke via Digitalmars-d-learn
On Sunday, 17 May 2020 at 03:30:57 UTC, Adnan wrote: In my machine, if you feed "aa" and "bbc" to the function, ldc generated code takes around 400 microseconds. I don't have an access to gdc in my machine. https://imgshare.io/image/NN8Xmp Full code: D : https://run.dlang.io/is/vLj7BC

Re: Linker error under Ubuntu

2020-05-15 Thread kinke via Digitalmars-d-learn
On Thursday, 14 May 2020 at 16:09:16 UTC, solidstate1991 wrote: When I try to compile my own project under Ubuntu with dub, I get the following linker error: /usr/bin/ld: .dub/obj/pixelperfectengine_pixelperfecteditor.o: undefined reference to symbol 'inflateEnd'

Re: Is is a Bug or just me?

2020-05-08 Thread kinke via Digitalmars-d-learn
On Friday, 8 May 2020 at 14:16:10 UTC, foerdi wrote: Now I am unsure if this is a bug or an undefined behavior that I don't know. This is a regression, and a potentially pretty bad one, so thx for tracking it down! If this is a bug, then I don't know how to call it for the bug tracker.

Re: XMM Intrinsics

2020-05-08 Thread kinke via Digitalmars-d-learn
On Friday, 8 May 2020 at 13:30:42 UTC, Marcio Martins wrote: I saw the intel-intrinsics package, but unfortunately it stops at SEE3 and I need SSE4.2 for this. How is this library working? It's open source. :) Will LDC/LLVM detect the name and replace it with the right instructions? If so,

Re: XMM Intrinsics

2020-05-08 Thread kinke via Digitalmars-d-learn
On Friday, 8 May 2020 at 12:49:00 UTC, Simen Kjærås wrote: How would I go about calling _mm_* functions in D in a way that is portable between D compilers? You would use core.simd: Nope one wouldn't, because that horrible interface isn't supported by LDC, and I guess GDC neither. The

Re: real operations imprecise?

2020-05-05 Thread kinke via Digitalmars-d-learn
I can't even reproduce the 'missing' digits. On run.dlang.io, i.e., on Linux x64 (and so x87 real), I get an identical output for both DMD and LDC: void main() { import core.stdc.stdio, std.math; printf("%.70Lf\n", PI); printf("%.70Lf\n", PI_2); printf("%La\n", PI);

Re: Idomatic way to guarantee to run destructor?

2020-05-04 Thread kinke via Digitalmars-d-learn
On Monday, 4 May 2020 at 11:50:49 UTC, Steven Schveighoffer wrote: I'm not sure if Ali is referring to this, but the usage of scope to allocate on the stack was at one time disfavored by the maintainers. This is why std.typecons.scoped was added (to hopefully remove that feature). Though, if

Re: How can I fully include "libdruntime-ldc.a" and "libphobos2-ldc.a" in my .so lib ?

2020-04-16 Thread kinke via Digitalmars-d-learn
On Thursday, 16 April 2020 at 10:04:54 UTC, Basile B. wrote: Just got it to work using "libs" : [ "druntime-ldc", "phobos2-ldc" ] $ ldc2 -help | grep -- -link-defaultlib-shared --link-defaultlib-shared - Link with shared versions of default libraries. Defaults to

Re: A question about C++ interop

2020-03-29 Thread kinke via Digitalmars-d-learn
On Sunday, 29 March 2020 at 15:20:52 UTC, YD wrote: So what do I need to declare in the D file for it to match the library entry? Thanks! This is similar to https://issues.dlang.org/show_bug.cgi?id=19260, and can be worked around the same way by messing manually with the mangled name, if

Re: Output predefined versions

2020-03-25 Thread kinke via Digitalmars-d-learn
On Wednesday, 25 March 2020 at 17:22:51 UTC, Dan Cirnat wrote: Is there a quick way to check which ones are predefined? Yes, just dummy-compile something with `-v` and check the line starting with `predefs`.

Re: Strip Unused Symbols Ldc + Windows

2020-03-21 Thread kinke via Digitalmars-d-learn
On Saturday, 21 March 2020 at 17:33:21 UTC, SrMordred wrote: Hmm, ok, my question is in fact relate to this kind of thing: https://godbolt.org/z/NGjyyx Why int example.add(int, int): its still on the binary when all u need is alredy optimized to main: mov eax, 30 ret ? You're

Re: Strip Unused Symbols Ldc + Windows

2020-03-21 Thread kinke via Digitalmars-d-learn
On Saturday, 21 March 2020 at 01:54:00 UTC, SrMordred wrote: Someone knows how to strip unused symbols on final binary using ldc on windows ? i found this about this topic: https://forum.dlang.org/post/yvmnkvzgoxhcfavja...@forum.dlang.org that uses --gc-sections and --version-script but this

Re: dub and -lowmem: does nothing

2020-03-20 Thread kinke via Digitalmars-d-learn
On Friday, 20 March 2020 at 23:37:52 UTC, Anonymouse wrote: 4. If I run dub with -v on the lowmem configuration and copy/paste *the same command it ran*, unmodified, I suddenly get the more expected ~1183 Mb used. [...] -lowmem is visibly present in the dmd command listed with -v, but it

Re: DMD 2.090.1: SIGILL, Illegal instruction on (ahem) intel Pentium III

2020-03-11 Thread kinke via Digitalmars-d-learn
On Wednesday, 11 March 2020 at 22:18:04 UTC, kdevel wrote: Disassembly on the AMD 64 it reveals that ldc also emits the movds instructions: 0x08051ba2 <+434>: call 0x804f680 <_D2rt5minfo11ModuleGroup6__ctorMFNbNcNiAyPS6object10ModuleInfoZSQCkQCkQCh> 0x08051ba7 <+439>: sub

Re: Using LDC2 on ARM

2020-03-02 Thread kinke via Digitalmars-d-learn
On Monday, 2 March 2020 at 17:45:26 UTC, Severin Teona wrote: Is there any reason why the LDC team stopped releasing pre-built binaries for arm? It's the only package that isn't auto-generated by CI services and requires manual steps in a painfully slow qemu environment, a process that takes

Re: Strange counter-performance in an alternative `decimalLength9` function

2020-02-28 Thread kinke via Digitalmars-d-learn
On Friday, 28 February 2020 at 10:11:23 UTC, Bruce Carneal wrote: On Friday, 28 February 2020 at 06:50:55 UTC, 9il wrote: bsr can be done in one/two CPU operation, quite quick. But core.bitop.bsr wouldn't be inlined. Instead, mir-core (mir.bitop: ctlz) or LDC intrinsics llvm_ctlz can be used

Re: Lambda capture by value

2020-02-24 Thread kinke via Digitalmars-d-learn
On Monday, 24 February 2020 at 19:50:23 UTC, JN wrote: foreach (i; iota(5)) { printers[i] = () { write(i); }; } This allocates 1 closure and generates 1 lambda, so all printers are identical delegates. You could use a static foreach: NumberPrinter[] printers; static

Re: Porting D to custom OS

2020-02-22 Thread kinke via Digitalmars-d-learn
On Saturday, 22 February 2020 at 13:20:40 UTC, IGotD- wrote: Do we have any guide for OS porting? I'd suggest to first hack the compiler, so that it doesn't predefine the host OS, but a new version for your OS (and check whether predefining `version (Posix)` is appropriate or not). That

Re: State of MIPS

2020-02-19 Thread kinke via Digitalmars-d-learn
On Wednesday, 19 February 2020 at 07:09:02 UTC, April wrote: What's the current state of MIPS compiling for bare metal? For LDC, bare metal should hardly be a problem; most druntime/Phobos tests apparently pass, see https://github.com/ldc-developers/ldc/issues/2995.

Re: Printing LHS and RHS of assert expressions on failure

2020-02-11 Thread kinke via Digitalmars-d-learn
On Tuesday, 11 February 2020 at 13:38:32 UTC, Adnan wrote: I just want to know is there any de-facto way of achieving this? See the `-checkaction=context` switch.

Re: How to call a extern C++ class constructor ?

2020-02-01 Thread kinke via Digitalmars-d-learn
On Saturday, 1 February 2020 at 14:52:21 UTC, kinke wrote: Trivial cases like yours should actually work wrt. using C++ ctor implementations from D IIRC. Ah, you need at least one virtual function in the C++ class (because D always reserves a vptr, the pointer to the class vtable).

Re: How to call a extern C++ class constructor ?

2020-02-01 Thread kinke via Digitalmars-d-learn
On Saturday, 1 February 2020 at 08:15:20 UTC, Luhrel wrote: But somehow I got a segfault on dcpp.getNumber(true). That's because you declare it as virtual in D (default for classes, use `final`), but non-virtual in C++. You also forgot to add the class field to the D declaration (yes, D

Re: Information about the 'magic' field in object.Object class

2020-01-16 Thread kinke via Digitalmars-d-learn
On Thursday, 16 January 2020 at 15:28:06 UTC, realhet wrote: Update: - All of the child classes needed to be marked with extern(C++) - static class members are not supported, only __gshared static. - passing a delegate to a constructor of this class expects a (extern(C++) delegate) too. -

Re: Easiest way to use FMA instruction

2020-01-10 Thread kinke via Digitalmars-d-learn
On Friday, 10 January 2020 at 00:02:52 UTC, Johan wrote: For LDC: [...] Simpler variant: ``` import ldc.intrinsics; ... const result = llvm_fma(a, b, c); ``` This LLVM intrinsic is also used in LDC's Phobos for std.math.fma(); unfortunately, upstream Phobos just has a `real`-version, so

Re: Practical parallelization of D compilation

2020-01-08 Thread kinke via Digitalmars-d-learn
On Wednesday, 8 January 2020 at 04:40:02 UTC, Guillaume Lathoud wrote: * first run (compiling everything): 50% to 100% slower than classical compilation, depending on the hardware, resp. on an old 4-core or a more recent 8-core. If parallel compiler invocations for each source file

Re: What is the simplest way to download and set path variables for D compilers when using AppVeyor

2019-11-27 Thread kinke via Digitalmars-d-learn
On Wednesday, 27 November 2019 at 19:02:08 UTC, Michael Brockus wrote: I am wondering if you guys would know what maybe the simplest way to have D working on AppVeyor Probably something like this: https://github.com/kinke/ldc/blob/e484486364f6765cb35d9d2961b05647ae78552b/appveyor.yml#L67-L69

Re: Why same pointer type for GC and manual memory?

2019-11-14 Thread kinke via Digitalmars-d-learn
On Thursday, 14 November 2019 at 01:08:58 UTC, Suleyman wrote: On Wednesday, 13 November 2019 at 16:43:27 UTC, IGotD- wrote: Best example is probably managed C++, an MS extension to C++ which is now deprecated. MS Managed C++ was superseded by C++/CLI[1] which was standardized. They actually

Re: Does betterC work different on windows and linux?

2019-11-14 Thread kinke via Digitalmars-d-learn
On Thursday, 14 November 2019 at 16:34:07 UTC, Ferhat Kurtulmuş wrote: I could also run the code in that way. Probably I have some problems with dub configurations. I get linking errors when I try to import the library in a newly created dub project, although there is "dflags": ["-betterC"] in

Re: Does betterC work different on windows and linux?

2019-11-14 Thread kinke via Digitalmars-d-learn
I can't reproduce this with LDC 1.17.0, after changing `unittest` to `extern (C) int main()` and returning 0 at the end; compiled & linked with `ldc2 -betterC stringnogc.d`.

Re: Troubleshooting DUB invocations

2019-11-12 Thread kinke via Digitalmars-d-learn
On Tuesday, 12 November 2019 at 16:44:06 UTC, Dukc wrote: When trying to compile a project including newest Spasm (DUB package) using the newest LDC via DUB, the result is: ``` lld: error: unknown argument: --no-as-needed ``` I then ran DUB with -v switch and it turned out the invocation

Re: rpath on macOS

2019-11-12 Thread kinke via Digitalmars-d-learn
On Tuesday, 12 November 2019 at 10:19:30 UTC, cartland wrote: but on macOS with DMD or LDC this gives ld: unknown option: -rpath=../../_cache/" IIRC, Mac's ld64 linker requires 2 separated args: "-rpath" "../../_cache/"

Re: is the runtime implemented in betterC?

2019-11-09 Thread kinke via Digitalmars-d-learn
On Friday, 8 November 2019 at 15:25:40 UTC, dangbinghoo wrote: On Friday, 8 November 2019 at 13:52:18 UTC, kinke wrote: On Friday, 8 November 2019 at 10:40:15 UTC, dangbinghoo wrote: hi, I'm not sure what you are trying to achieve; you can easily cross-compile druntime & Phobos with LDC,

Re: Default initialization of static array faster than void initialization

2019-11-08 Thread kinke via Digitalmars-d-learn
On Friday, 8 November 2019 at 16:49:37 UTC, wolframw wrote: I compiled with dmd -O -inline -release -noboundscheck -mcpu=avx2 and ran the tests with the m array being default-initialized in one run and void-initialized in another run. The results: Default-initialized: 245 ms, 495 μs, and 2

Re: is the runtime implemented in betterC?

2019-11-08 Thread kinke via Digitalmars-d-learn
On Friday, 8 November 2019 at 10:40:15 UTC, dangbinghoo wrote: hi, is the runtime d code implemented purely with betterC? i was thinking that what's happening when we building ARM dlang compiler, when the dlang compiler ready in the first, there's no ARM version of the runtime lib and

Re: Accuracy of floating point calculations

2019-10-29 Thread kinke via Digitalmars-d-learn
On Tuesday, 29 October 2019 at 16:20:21 UTC, Daniel Kozak wrote: On Tue, Oct 29, 2019 at 5:09 PM Daniel Kozak wrote: On Tue, Oct 29, 2019 at 4:45 PM Twilight via Digitalmars-d-learn wrote: > > D calculation: >mport std.stdio; import std.math : pow; import core.stdc.math; void main() {

Re: Can not understand this code.

2019-10-25 Thread kinke via Digitalmars-d-learn
On Friday, 25 October 2019 at 06:40:19 UTC, lili wrote: why need defined a alias Min in Min template? https://dlang.org/spec/template.html#implicit_template_properties

Re: dub build doesn't work

2019-10-23 Thread kinke via Digitalmars-d-learn
On Wednesday, 23 October 2019 at 16:55:37 UTC, OiseuKodeur wrote: On Wednesday, 23 October 2019 at 06:40:47 UTC, Seb wrote: You won't need Visual Studio for this, but something which ships msvcr100.dll. So sth. like this should be enough:

Re: Eliding of slice range checking

2019-10-23 Thread kinke via Digitalmars-d-learn
On Wednesday, 23 October 2019 at 13:08:34 UTC, Per Nordlöw wrote: Is it possible to remove cluttering? godbolt.org supports D as well and is way more powerful than run.dlang.io, besides offering way more LDC versions to choose from. It can also be used to remove the 'cluttering':

Re: Eliding of slice range checking

2019-10-23 Thread kinke via Digitalmars-d-learn
On Wednesday, 23 October 2019 at 13:08:34 UTC, Per Nordlöw wrote: The ASM- and IR-output from the following code is pretty messy for You call this messy?! cmpq%rdi, %rdx jae .LBB0_2 xorl%eax, %eax retq .LBB0_2: movq%rdi, %rax testq

Re: Eliding of slice range checking

2019-10-23 Thread kinke via Digitalmars-d-learn
On Wednesday, 23 October 2019 at 11:20:59 UTC, Per Nordlöw wrote: How can I investigate the codegen myself here? Simply check the IR or asm, e.g., on run.dlang.io. If there's a call to `_d_arraybounds` in the function of interest, bounds checks are enabled. For your example, the template

Re: using regex at compile time errors out! Error: static variable `thompsonFactory` cannot be read at compile time

2019-10-04 Thread kinke via Digitalmars-d-learn
Have you tried ctRegex?

Re: C++ base constructor call vs. D's

2019-10-02 Thread kinke via Digitalmars-d-learn
On Wednesday, 2 October 2019 at 17:22:40 UTC, Just Dave wrote: I was reading the C++ to D page, and came across this little bit about when to call the base class constructor: Isn't there some inherent danger of not calling the base constructor first? The object's fields are pre-initialized

Re: Static initialization of rectangular arrays

2019-08-29 Thread kinke via Digitalmars-d-learn
On Thursday, 29 August 2019 at 18:59:22 UTC, kinke wrote: On Thursday, 29 August 2019 at 18:11:50 UTC, Les De Ridder wrote: It's a known bug[1]. As a workaround you could use a `static this()`: Or LDC, and GDC probably too. Sorry, that was wrt. the linked bugzilla and not this example

Re: Static initialization of rectangular arrays

2019-08-29 Thread kinke via Digitalmars-d-learn
On Thursday, 29 August 2019 at 18:11:50 UTC, Les De Ridder wrote: It's a known bug[1]. As a workaround you could use a `static this()`: Or LDC, and GDC probably too.

Re: How to set a global var to a user defined section.

2019-08-20 Thread kinke via Digitalmars-d-learn
On Tuesday, 20 August 2019 at 17:33:17 UTC, lili wrote: Hi: With gcc we can use _ attribute _((section("name")) var; how to same in dlang? As for C(++), not standardized in the language itself. With LDC: import ldc.attributes : section; @section("name") __gshared int myGlobal;

Re: /usr/bin/ld.gold: error: failed to find object -lz

2019-08-15 Thread kinke via Digitalmars-d-learn
On Thursday, 15 August 2019 at 11:28:35 UTC, Dukc wrote: > https://software.opensuse.org/package/zlib-devel-static An error when installing, apparently internal. That's the library you need. You may have messed things up by installing a non-dev package from Fedora (!).

Re: Abstract classes vs interfaces, casting from void*

2019-08-09 Thread kinke via Digitalmars-d-learn
On Friday, 9 August 2019 at 12:26:59 UTC, John Colvin wrote: Why is there no "hi" between 0 and 1? Because you are treating the unadjusted object pointer as interface pointer and then call the only virtual function of that interface, in the 2nd vtbl slot (after the TypeInfo ptr). Casting a

Re: Module static constructor doesn't work?

2019-08-08 Thread kinke via Digitalmars-d-learn
On Thursday, 8 August 2019 at 14:55:37 UTC, Andrey Zherikov wrote: But if I create library from lib.d first and then link it with main.d then ctor/dtor are not called: For this to work as expected, the `lib.obj` object file needs to be linked into the final executable. As main.d doesn't need

Re: How to mark a condition is likeyly or unlikey ?

2019-08-07 Thread kinke via Digitalmars-d-learn
On Wednesday, 7 August 2019 at 11:37:06 UTC, lili wrote: How to do this in Dlang? Just as in C, this isn't standardized, and I don't think DMD has such a thing. For LDC, see https://forum.dlang.org/thread/ecycecfohgcqkfapi...@forum.dlang.org.

Re: /usr/bin/ld.gold: error: failed to find object -lz

2019-08-06 Thread kinke via Digitalmars-d-learn
On Tuesday, 6 August 2019 at 11:25:29 UTC, Dukc wrote: I did notice that according to the above, `-lz` argument apparently is due to an attempt by dub or ldc to pass `-z` to the linker, but I'm just not getting ideas of how to troubleshoot that further. Any ideas? LDC definitely doesn't add

Re: How do I display unicode characters in D on standard (english) Windows 10 console window?

2019-07-30 Thread kinke via Digitalmars-d-learn
On Tuesday, 30 July 2019 at 12:06:23 UTC, Martin Krejcirik wrote: Just be advised, this was seriously broken in the past. Depends on windows, ms libraries, whether it's stdout or stderr and more. Current versions are probably ok, will check. Don't count on this to work on older windows

Re: How do I display unicode characters in D on standard (english) Windows 10 console window?

2019-07-29 Thread kinke via Digitalmars-d-learn
On Monday, 29 July 2019 at 22:17:55 UTC, WhatMeWorry wrote: What am I missing? Switching the console code page to UTF-8, and then restoring the original one before termination. See

  1   2   3   >