Re: Converting a ubyte[] to a struct with respect to endianness?

2017-06-23 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jun 23, 2017 at 10:10:22PM -0700, Ali Çehreli via Digitalmars-d-learn wrote: > On 06/23/2017 09:26 PM, Felix wrote: > > That works, thanks! > > I've just tried this, which seems cleaner: > > import std.stdio; > import std.system; > import std.bitmanip; > > void ensureBigEndian(T)(ref T

Re: Converting a ubyte[] to a struct with respect to endianness?

2017-06-23 Thread Ali Çehreli via Digitalmars-d-learn
On 06/23/2017 09:26 PM, Felix wrote: That works, thanks! I've just tried this, which seems cleaner: import std.stdio; import std.system; import std.bitmanip; void ensureBigEndian(T)(ref T value) { if (endian == Endian.littleEndian) { value = *cast(T*)nativeToBigEndian(value).ptr;

Re: Converting a ubyte[] to a struct with respect to endianness?

2017-06-23 Thread Felix via Digitalmars-d-learn
That works, thanks!

Re: Converting a ubyte[] to a struct with respect to endianness?

2017-06-23 Thread Ali Çehreli via Digitalmars-d-learn
On 06/23/2017 07:52 PM, Felix wrote: > So I'm guessing my ubytes are in the wrong order in the uint... how should I put them around the correct way so that my code won't break on another machine with different endianness? Yes, that would happen when your system is little-endian. (According to

Converting a ubyte[] to a struct with respect to endianness?

2017-06-23 Thread Felix via Digitalmars-d-learn
I'm trying to read in just the first part of a .png file to peek at it's width and height without loading in the whole file. I'm using FreeImage for reading the whole file but since it doesn't have a function to let me peek at the image size before loading it all in I'm rolling my own. I've

Re: implib.exe no output files

2017-06-23 Thread Joel via Digitalmars-d-learn
On Wednesday, 21 June 2017 at 11:30:56 UTC, Ivan Kazmenko wrote: [...] Step 5. I don't get any lib files. I got lib files on another computer, though.

Re: Read conditional function parameters during compile time using __traits

2017-06-23 Thread timvol via Digitalmars-d-learn
On Wednesday, 21 June 2017 at 20:48:52 UTC, ag0aep6g wrote: On 06/21/2017 09:39 PM, timvol wrote: size_t calcLength(ubyte ubFuncCode)() if ( ubFuncCode == 1 ) { return 10; // More complex calculated value } size_t calcLength(ubyte ubFuncCode)() if ( ubFuncCode ==

Re: How to add class in DIET template

2017-06-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/23/17 12:06 PM, Martin Tschierschke wrote: You can use the html syntax for the class parameter, the funny/nice thing is, that mystr can be used directly without "#{}" around. code(class=mystr) #{line} works. Yes, I just found out recently -- when you don't use quotes for an attribute

Re: How to add class in DIET template

2017-06-23 Thread Martin Tschierschke via Digitalmars-d-learn
On Friday, 23 June 2017 at 06:59:22 UTC, Suliman wrote: I need to get external variable and make class by it's value - string mystr = "lng-" ~ language; - foreach(i, line; arrayOfLines ) li code.mystr #{line} I need to get HTML code like this: some D code But class

Re: Cannot implicitly convert expression (struct this)

2017-06-23 Thread Kagamin via Digitalmars-d-learn
On Thursday, 22 June 2017 at 09:57:44 UTC, Andre Pany wrote: This line raises the error: TestStruct s2 = TestStruct(Reason.FU); Error: cannot implicitly convert expression ("Fu") of type Reason to InitialEnum!(Reason) While this line is working fine: TestStruct s1 = {reason: Reason.FU}; I

Re: Immutable

2017-06-23 Thread ag0aep6g via Digitalmars-d-learn
On 06/23/2017 04:29 PM, Adam D. Ruppe wrote: try `new immutable AppendChatCommand` instead of just `new`. If it complains that it cannot call the mutable constructor, go to the class definition and add `pure` to the constructor. Should take care of that error. With a `pure` constructor,

Re: Dealing with the interior pointers bug

2017-06-23 Thread Russel Winder via Digitalmars-d-learn
On Thu, 2017-06-22 at 18:38 +, Boris-Barboris via Digitalmars-d- learn wrote: > […] > > Casts are part of the type system. Yes, D type system allows  > invalid operations. It's not the compiler's fault, it's type  > system's fault. > […] Well maybe casts should be allowed as they effectively

Re: Immutable

2017-06-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 23 June 2017 at 14:29:41 UTC, harakim wrote: heh. I've been working on this for an hour or so. Right after I posted, I tried casting it, which worked. Thank you for your time. cast works, but `new immutable` with a pure ctor should work better. (casts are easy to get wrong so best

Re: Immutable

2017-06-23 Thread harakim via Digitalmars-d-learn
On Friday, 23 June 2017 at 14:29:40 UTC, Adam D. Ruppe wrote: On Friday, 23 June 2017 at 14:25:48 UTC, harakim wrote: immutable(AppendChatCommand) command = new AppendChatCommand(type, text); try `new immutable AppendChatCommand` instead of just `new`. If it complains that it cannot call the

Re: Immutable

2017-06-23 Thread harakim via Digitalmars-d-learn
On Friday, 23 June 2017 at 14:25:48 UTC, harakim wrote: I am building a system where one thread generates commands and sends them to another thread. The commands will never change once they are created. I have marked the values immutable, but I've been struggling to understand the requirements

Re: Immutable

2017-06-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 23 June 2017 at 14:25:48 UTC, harakim wrote: immutable(AppendChatCommand) command = new AppendChatCommand(type, text); try `new immutable AppendChatCommand` instead of just `new`. If it complains that it cannot call the mutable constructor, go to the class definition and add

Immutable

2017-06-23 Thread harakim via Digitalmars-d-learn
I am building a system where one thread generates commands and sends them to another thread. The commands will never change once they are created. I have marked the values immutable, but I've been struggling to understand the requirements for sharing a variable across threads. cannot

Re: GDC generate wrong .exe ("not a valid win32 application")

2017-06-23 Thread PATRIC DEXHEIMER via Digitalmars-d-learn
On Wednesday, 21 June 2017 at 15:55:27 UTC, David Nadlinger wrote: On Monday, 19 June 2017 at 14:08:56 UTC, Patric Dexheimer wrote: Fresh install of GDC. (tried with 32x ad 32_64x) Where did you get the GDC executable from? The GDC project doesn't currently offer any official builds that

Re: Dub command line knowledge sought

2017-06-23 Thread Russel Winder via Digitalmars-d-learn
On Fri, 2017-06-23 at 09:24 +, Laeeth Isharc via Digitalmars-d- learn wrote: > […] > > Check out the Kaleidic fork maintained by John Colvin - currently > in his personal repository on github. We submitted back our > changes but ended up being quite a lot so not all have been > accepted

Re: Dub command line knowledge sought

2017-06-23 Thread Laeeth Isharc via Digitalmars-d-learn
On Friday, 23 June 2017 at 08:26:21 UTC, Russel Winder wrote: On Fri, 2017-06-23 at 08:11 +, Nicholas Wilson via Digitalmars-d- learn wrote: On Friday, 23 June 2017 at 07:51:51 UTC, Russel Winder wrote: > I am likely just staring at and missing the data needed: > > How does one invoke dub

Re: Dub command line knowledge sought

2017-06-23 Thread Russel Winder via Digitalmars-d-learn
On Fri, 2017-06-23 at 08:11 +, Nicholas Wilson via Digitalmars-d- learn wrote: > On Friday, 23 June 2017 at 07:51:51 UTC, Russel Winder wrote: > > I am likely just staring at and missing the data needed: > > > > How does one invoke dub to fetch and build, and put into a > > place other that

Re: Dub command line knowledge sought

2017-06-23 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 23 June 2017 at 07:51:51 UTC, Russel Winder wrote: I am likely just staring at and missing the data needed: How does one invoke dub to fetch and build, and put into a place other that ~/.dub/… a package from Dub? dub fetch foo --version=1.0.0 mv ~/.dub/packages/foo-1.0.0

Dub command line knowledge sought

2017-06-23 Thread Russel Winder via Digitalmars-d-learn
I am likely just staring at and missing the data needed: How does one invoke dub to fetch and build, and put into a place other that ~/.dub/… a package from Dub? -- Russel. = Dr Russel Winder t: +44 20 7585 2200

How to add class in DIET template

2017-06-23 Thread Suliman via Digitalmars-d-learn
I need to get external variable and make class by it's value - string mystr = "lng-" ~ language; - foreach(i, line; arrayOfLines ) li code.mystr #{line} I need to get HTML code like this: some D code But class name become "mystr" and I am getting: some D code How