Re: Lack of asm volatile qualifier (explicitly) again.

2020-07-31 Thread Cecil Ward via Digitalmars-d-learn
On Thursday, 30 July 2020 at 07:05:39 UTC, Iain Buclaw wrote: On Tuesday, 28 July 2020 at 06:57:36 UTC, Cecil Ward wrote: I read recently that all asm in D is regarded as ‘volatile’ in the GCC sense, which I take to mean that it is assume to potentially have side effects, and so cannot be optim

Using D with PlatformIO

2020-07-31 Thread MoonlightSentinel via Digitalmars-d-learn
Currently working on a PlatformIO [1] based project in C++ and want to throw some D into the mix. Couldn't find an existing solution and I'm not sure how to implement a proper solution using PIO's scripting capabilities. Did somebody try this before and could share his experiences? [1] https:

Re: 2-D array initialization

2020-07-31 Thread MoonlightSentinel via Digitalmars-d-learn
On Friday, 31 July 2020 at 23:42:45 UTC, Andy Balba wrote: How does one initialize c in D ? ubyte[3][4] c = [ [5, 5, 5], [15, 15,15], [25, 25,25], [35, 35,35] ]; none of the statements below works c = cast(ubyte) [ [5, 5, 5], [15, 15,15], [25, 25,25], [35, 35,35] ]; This is an invali

Re: 2-D array initialization

2020-07-31 Thread jmh530 via Digitalmars-d-learn
On Friday, 31 July 2020 at 23:42:45 UTC, Andy Balba wrote: ubyte[3][4] c ; How does one initialize c in D ? none of the statements below works c = cast(ubyte) [ [5, 5, 5], [15, 15,15], [25, 25,25], [35, 35,35] ]; c[0] = ubyte[3] [5, 5, 5] ; c[1] = ubyte[3] [15, 15,15] ; c[2] = ubyte[

2-D array initialization

2020-07-31 Thread Andy Balba via Digitalmars-d-learn
ubyte[3][4] c ; How does one initialize c in D ? none of the statements below works c = cast(ubyte) [ [5, 5, 5], [15, 15,15], [25, 25,25], [35, 35,35] ]; c[0] = ubyte[3] [5, 5, 5] ; c[1] = ubyte[3] [15, 15,15] ; c[2] = ubyte[3] [25, 25,25] ; c[3] = ubyte[3] [35, 35,35] ; for (int i=

Re: dlib 0.19.1 seems to be failing linking with ldc2

2020-07-31 Thread jeff thompson via Digitalmars-d-learn
On Friday, 31 July 2020 at 20:07:26 UTC, Dennis wrote: On Friday, 31 July 2020 at 14:17:14 UTC, jeff thompson wrote: dlib.lib(dlib.audio.io.wav.obj) : error LNK2019: unresolved external symbol _D4core8internal7switch___T14__switch_errorZQrFNaNbNiNfAyamZv referenced in function _D3std6format__

Re: dlib 0.19.1 seems to be failing linking with ldc2

2020-07-31 Thread Dennis via Digitalmars-d-learn
On Friday, 31 July 2020 at 14:17:14 UTC, jeff thompson wrote: dlib.lib(dlib.audio.io.wav.obj) : error LNK2019: unresolved external symbol _D4core8internal7switch___T14__switch_errorZQrFNaNbNiNfAyamZv referenced in function _D3std6format__T10printFloatTfTaZQrFNaNfNkAafSQBsQBr__T10FormatSpecTaZQ

Re: arrays in srucs

2020-07-31 Thread Andy Balba via Digitalmars-d-learn
On Friday, 31 July 2020 at 17:26:17 UTC, Paul Backus wrote: On Friday, 31 July 2020 at 17:02:46 UTC, Andy Balba wrote: The above code, compiles and runs ok .. but sometimes I get run runtime errors using the same paradym, which disappear when I substitute (img.p)[i] Any explanation for this

Re: arrays in srucs

2020-07-31 Thread Paul Backus via Digitalmars-d-learn
On Friday, 31 July 2020 at 17:02:46 UTC, Andy Balba wrote: The above code, compiles and runs ok .. but sometimes I get run runtime errors using the same paradym, which disappear when I substitute (img.p)[i] Any explanation for this ? Can you show an example where it doesn't work?

arrays in srucs

2020-07-31 Thread Andy Balba via Digitalmars-d-learn
I frequently use this paradigm for my image processing apps : import std.stdio ; struct S { int a, b; ubyte[] p; } void main() { S img= S(11,22) ; img.p = new ubyte[5]; foreach (i; 0 .. 5) { img.p[i]=cast(ubyte)(10+i) ; printf(" sa %d sb %d : %d\n", img.a, img.b, img.p[i] ); } } The above

Re: dynamic array .length vs .reserve - what's the difference?

2020-07-31 Thread wjoe via Digitalmars-d-learn
On Friday, 31 July 2020 at 04:28:57 UTC, Ali Çehreli wrote: Yes but the "sharing being terminated" phrase was my attempt at explaining things, which did not catch on. :) Real shame. I quite like it - especially if you say it out loud with an Austrian accent :) Another option, which is curio

Re: Gotcha with const std.range.chunks

2020-07-31 Thread sportsracer via Digitalmars-d-learn
Right, thank you! The range object needs to be mutated to be iterated on, that explains it. Although it looks like the opIndex on this particular range could guarantee constness: https://github.com/dlang/phobos/blob/v2.093.0/std/range/package.d#L8099 Here's a longer code snippet that gives s

Re: D on lm32-CPU: string argument on stack instead of register

2020-07-31 Thread Johan via Digitalmars-d-learn
On Friday, 31 July 2020 at 10:22:20 UTC, Michael Reese wrote: My question: Is there a way I can tell the D compiler to use registers instead of stack for string arguments, or any other trick to reduce code size while maintaining an ideomatic D codestyle? A D string is a "slice", which is a

Re: Idiomatic D code to avoid or detect devision by zero

2020-07-31 Thread Andrea Fontana via Digitalmars-d-learn
On Friday, 31 July 2020 at 13:55:18 UTC, Martin Tschierschke wrote: What would be the idiomatic way to write a floating point division occuring inside a loop and handle the case of division by zero. c = a/b; // b might be zero sometimes, than set c to an other value (d). (In the moment I che

Re: D on lm32-CPU: string argument on stack instead of register

2020-07-31 Thread Chad Joan via Digitalmars-d-learn
On Friday, 31 July 2020 at 10:22:20 UTC, Michael Reese wrote: Hi all, at work we put embedded lm32 soft-core CPUs in FPGAs and write the firmware in C. At home I enjoy writing small projects in D from time to time, but I don't consider myself a D expert. Now, I'm trying to run some toy examp

Re: dlib 0.19.1 seems to be failing linking with ldc2

2020-07-31 Thread jeff thompson via Digitalmars-d-learn
Also this is on x86_x64 box and the 2019 MSVC toolchain

Re: Idiomatic D code to avoid or detect devision by zero

2020-07-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/31/20 9:55 AM, Martin Tschierschke wrote: What would be the idiomatic way to write a floating point division occuring inside a loop and handle the case of division by zero. c = a/b; // b might be zero sometimes, than set c to an other value (d). (In the moment I check the divisor being zer

dlib 0.19.1 seems to be failing linking with ldc2

2020-07-31 Thread jeff thompson via Digitalmars-d-learn
Hello Im using dlib 0.19.1 with a project and compiling with ldc2 1.22 its failing with the error below. This works fine with the latest dmd version. My targetType is a static lib, only other dependencies are latest bindbc-glfw and bindbc-gl Performing "debug" build using ldc2.exe for x86_64

Idiomatic D code to avoid or detect devision by zero

2020-07-31 Thread Martin Tschierschke via Digitalmars-d-learn
What would be the idiomatic way to write a floating point division occuring inside a loop and handle the case of division by zero. c = a/b; // b might be zero sometimes, than set c to an other value (d). (In the moment I check the divisor being zero or not, with an if-than-else structure, bu

D on lm32-CPU: string argument on stack instead of register

2020-07-31 Thread Michael Reese via Digitalmars-d-learn
Hi all, at work we put embedded lm32 soft-core CPUs in FPGAs and write the firmware in C. At home I enjoy writing small projects in D from time to time, but I don't consider myself a D expert. Now, I'm trying to run some toy examples in D on the lm32 cpu. I'm using a recent gcc-elf-lm32. I s

Re: dynamic array .length vs .reserve - what's the difference?

2020-07-31 Thread ag0aep6g via Digitalmars-d-learn
On 31.07.20 01:42, wjoe wrote: I could swear just a few weeks ago there was someone asking how to tell if an array was null or of length 0 and an answer was that it's the same and can't be distinguished so I assumed that assigning a slice of 0 length is the same as setting the array to null bec

Re: Why does stringof not like functions with arguments?

2020-07-31 Thread Chad Joan via Digitalmars-d-learn
On Thursday, 10 August 2017 at 14:51:22 UTC, Meta wrote: On Wednesday, 9 August 2017 at 01:39:07 UTC, Jason Brady wrote: Why does the following code error out with: app.d(12,10): Error: function app.FunctionWithArguments (uint i) is not callable using argument types () Code: import std.stdi