Re: write struct as raw data to file

2021-09-26 Thread Vitaliy Fadeev via Digitalmars-d-learn
On Sunday, 26 September 2021 at 15:09:38 UTC, Paul wrote: Is there way to write the myStruct data to the file in a single statement...or two? Thanks for any assistance. Header[1] header; void readFileHeader( ref File f ) { f.rawRead( header ); }

Re: write struct as raw data to file

2021-09-26 Thread Paul via Digitalmars-d-learn
Finished product... ~15k samples x 2 sin() waves/composite wave x 16 DTMF tones = 16 DTMF wave files in ~40ms! I love D.

Re: write struct as raw data to file

2021-09-26 Thread Paul via Digitalmars-d-learn
What's with the 4 bytes of zero? I miss-counted. All is well! Thanks Ali / Steven

Re: write struct as raw data to file

2021-09-26 Thread Paul via Digitalmars-d-learn
Hmm...well this is what I did and sort of got what I wanted; it did compile and write data! auto myStruct = new mystruct[1]; File f = File("myFile.wav", "wb"); f.rawWrite(myStruct); //this is 44 bytes f.rawWrite(shortWaveArray); What I got in the file was this: -my 44 byte myStruct data + (4

Re: AVX for math code ... avx instructions later disappearing ?

2021-09-26 Thread james.p.leblanc via Digitalmars-d-learn
On Sunday, 26 September 2021 at 19:00:54 UTC, kinke wrote: On Sunday, 26 September 2021 at 18:08:46 UTC, james.p.leblanc wrote: or even moving the array declarations to before the dot product function, and the avx instructions will disappear! That's because the `@fastmath` UDA applies to the

Re: AVX for math code ... avx instructions later disappearing ?

2021-09-26 Thread kinke via Digitalmars-d-learn
On Sunday, 26 September 2021 at 18:08:46 UTC, james.p.leblanc wrote: or even moving the array declarations to before the dot product function, and the avx instructions will disappear! That's because the `@fastmath` UDA applies to the next declaration only, which is the `x` array in your 2nd

AVX for math code ... avx instructions later disappearing ?

2021-09-26 Thread james.p.leblanc via Digitalmars-d-learn
Dear D-ers, I enjoyed reading some details of incorporating AVX into math code from Johan Engelen's programming blog post: http://johanengelen.github.io/ldc/2016/10/11/Math-performance-LDC.html Basically, one can use the ldc compiler to insert avx code, nice! In playing with some variants of

Re: write struct as raw data to file

2021-09-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/26/21 11:09 AM, Paul wrote: I'm building a binary file.  I can write my 'short[] myArray' directly to the file using: File f = File( "myFile.wav", "wb" ); f.rawWrite(myArray); It doesn't write any array formatting stuff (i.e. '[ ,  , ]'); it just moves the data into myFile like I want.

Re: Where is the core.sys (and std.windows) documentation?

2021-09-26 Thread Adam D Ruppe via Digitalmars-d-learn
Some are available on my website http://druntime.dpldocs.info/core.sys.html but the source doesn't include much so it is a bit sparse and all the version overloads can be awkward to read.

Where is the core.sys (and std.windows) documentation?

2021-09-26 Thread SomeGuy via Digitalmars-d-learn
I can't find the core.sys documentation in the library reference. I thought that functionality was removed but clearly the source files exist in druntime: https://github.com/dlang/druntime/tree/master/src/core/sys Same goes for std.windows:

Re: write struct as raw data to file

2021-09-26 Thread Ali Çehreli via Digitalmars-d-learn
Correcting my sloppy code. :) On 9/26/21 8:53 AM, Ali Çehreli wrote: >// We need an array Ses (length of 1 in this case) >auto ses = new S[1]; Allocating a dynamic array there is egregious pessimization. The following works the same but this time the static array of a single S will be

Re: write struct as raw data to file

2021-09-26 Thread Ali Çehreli via Digitalmars-d-learn
rawRead and rawWrite work with slices (arrays) of things. You need to use an array of your struct even if there is a single item. Here is an example: import std.stdio; import std.file; struct S { int i; double d; } void readFrom(string name) { // We need an array Ses (length of 1 in

write struct as raw data to file

2021-09-26 Thread Paul via Digitalmars-d-learn
I'm building a binary file. I can write my 'short[] myArray' directly to the file using: File f = File( "myFile.wav", "wb" ); f.rawWrite(myArray); It doesn't write any array formatting stuff (i.e. '[ , , ]'); it just moves the data into myFile like I want. I can't seem to do this with

Re: better c fibers

2021-09-26 Thread SealabJaster via Digitalmars-d-learn
On Sunday, 26 September 2021 at 09:48:58 UTC, SealabJaster wrote: ... I feel I didn't make it clear enough that extracting the code would be way too much effort than its worth, especially since I'm not even sure it runs on Linux. So I really wouldn't suggest going down that route.

Re: better c fibers

2021-09-26 Thread SealabJaster via Digitalmars-d-learn
On Tuesday, 21 September 2021 at 09:37:30 UTC, Abby wrote: ... I'm not aware of any -betterC package specifically for coroutines. I have some work done in this regard, but sadly the library itself isn't really usable at all so if you want to put in the effort you'd have to probably extract

Re: better c fibers

2021-09-26 Thread Imperatorn via Digitalmars-d-learn
On Tuesday, 21 September 2021 at 09:37:30 UTC, Abby wrote: Hi there, I'm new in dlang I specially like betterC. I was hoping that d fibers would be implemented in without using classes, but there are not. Is there another way how to use async/await in dlang better c? Thank you for your help

Re: LDC 1.28.0-beta1

2021-09-26 Thread Imperatorn via Digitalmars-d-learn
On Saturday, 25 September 2021 at 21:32:56 UTC, kinke wrote: Argh, wrong forum section, proper (identical) post: https://forum.dlang.org/thread/hcwukzoamezbpzrbk...@forum.dlang.org 