Re: union.sizeof

2017-03-25 Thread zabruk70 via Digitalmars-d-learn
On Sunday, 26 March 2017 at 06:45:13 UTC, ketmar wrote: yes. you have a typo in second `writefln`: S1 instead of S2. ;-) thank you. another question, related to my first post: why size of S2.b1 and S2.b2 still 3, not 4? am i right: then align applied to members, compiler not change size of m

foreach, is and pointer

2017-03-25 Thread helxi via Digitalmars-d-learn
What's the difference between 1. string x = "abcd"; foreach(character; x) write(character); and string x = "abcd"; foreach(character; x[0..$]) write(character); 2. is and == 3. pointer and address and reference?

Re: union.sizeof

2017-03-25 Thread zabruk70 via Digitalmars-d-learn
On Sunday, 26 March 2017 at 06:38:59 UTC, zabruk70 wrote: oh sorry sorry - mistyping ok. DMD use padding, so for real container.sizeof i should use lastMemeber.offsetof+lastMemeber.sizeof

Re: union.sizeof

2017-03-25 Thread ketmar via Digitalmars-d-learn
zabruk70 wrote: On Sunday, 26 March 2017 at 05:09:15 UTC, ketmar wrote: most of the time either location or padding will work the same. hmm.. you ruined my expirence.. i made another experiment. whould you please explain me S2 size 6? thank you for you time. yes. you have a typo in second

Re: union.sizeof

2017-03-25 Thread zabruk70 via Digitalmars-d-learn
On Sunday, 26 March 2017 at 05:09:15 UTC, ketmar wrote: most of the time either location or padding will work the same. hmm.. you ruined my expirence.. i made another experiment. whould you please explain me S2 size 6? thank you for you time. https://dpaste.dzfl.pl/9a31b6e370a0 struct S1 //s

Re: Recommend: IDE and GUI library

2017-03-25 Thread Soulsbane via Digitalmars-d-learn
On Wednesday, 1 March 2017 at 20:23:57 UTC, aberba wrote: On Friday, 24 February 2017 at 22:44:55 UTC, XavierAP wrote: [...] Gtkd is obviously defacto for Linux ONLY, dlangui for cross platform app without native feel. But if you want something easy and flexible with native look and feel on

Re: union.sizeof

2017-03-25 Thread ketmar via Digitalmars-d-learn
zabruk70 wrote: Thank you ag0aep6g and ketmar!! I will use additional outside align. I want packing inside, you are right. But i check result size with assert() and failed. But for clearness... I was thinked, that align not changes SIZE, but changes LOCATION. I was thinked, that "align(X) unio

Re: Howto catch SocketOSException?

2017-03-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 26 March 2017 at 02:24:56 UTC, Jolly James wrote: You can ignore the loop()-method. It is not called as the application will never reach this statement, because it cannot, because it crashes already in the listen()-method in consequence of the exception that does not get caught by th

Re: Howto catch SocketOSException?

2017-03-25 Thread Jolly James via Digitalmars-d-learn
On Sunday, 26 March 2017 at 01:22:24 UTC, bauss wrote: On Sunday, 26 March 2017 at 00:34:03 UTC, Jolly James wrote: [...] This part: catch (std.socket.SocketOSException e) [...] [...] I know that inheritance stuff, but none (!) of them catches that strange exception either. You can ignor

Re: Howto catch SocketOSException?

2017-03-25 Thread bauss via Digitalmars-d-learn
On Sunday, 26 March 2017 at 00:34:03 UTC, Jolly James wrote: How do you catch an std.socket.SocketOSException? The following does not work, as the exception occurs anyway and leads to a crash: import ae.net.asockets; void main(string[] args) { TcpServer tcp = new TcpServer();

Re: union.sizeof

2017-03-25 Thread bauss via Digitalmars-d-learn
On Saturday, 25 March 2017 at 23:36:07 UTC, kinke wrote: On Saturday, 25 March 2017 at 22:45:22 UTC, ketmar wrote: zabruk70 wrote: [...] `align(1) union Union1` will do the trick. what you did is members packing. but the union itself is padded to integer size too. i.e. internal `align` wil

Howto catch SocketOSException?

2017-03-25 Thread Jolly James via Digitalmars-d-learn
How do you catch an std.socket.SocketOSException? The following does not work, as the exception occurs anyway and leads to a crash: import ae.net.asockets; void main(string[] args) { TcpServer tcp = new TcpServer(); try { tcp.listen(2345, "127.0.0.1c

Re: union.sizeof

2017-03-25 Thread kinke via Digitalmars-d-learn
On Saturday, 25 March 2017 at 22:45:22 UTC, ketmar wrote: zabruk70 wrote: //DMD 2.073.1 and latest 2.075.0-master-972eaed //Windows 7 32-bit union Union1 { align(1): byte[5] bytes5; struct { align(1): char char1; uint int1; } } void main () { import std.stdio:

Re: union.sizeof

2017-03-25 Thread kinke via Digitalmars-d-learn
On Saturday, 25 March 2017 at 22:54:30 UTC, zabruk70 wrote: But for clearness... I was thinked, that align not changes SIZE, but changes LOCATION. I was thinked, that "align(X) union Union1" just force compiler to place Union1 on boundaries of X bytes... In order for all Union1 instances in a

Re: union.sizeof

2017-03-25 Thread zabruk70 via Digitalmars-d-learn
Thank you ag0aep6g and ketmar!! I will use additional outside align. I want packing inside, you are right. But i check result size with assert() and failed. But for clearness... I was thinked, that align not changes SIZE, but changes LOCATION. I was thinked, that "align(X) union Union1" just for

Re: union.sizeof

2017-03-25 Thread ketmar via Digitalmars-d-learn
zabruk70 wrote: //DMD 2.073.1 and latest 2.075.0-master-972eaed //Windows 7 32-bit union Union1 { align(1): byte[5] bytes5; struct { align(1): char char1; uint int1; } } void main () { import std.stdio: writefln; writefln("Union1.sizeof=%d", Union1.sizeof);

Re: union.sizeof

2017-03-25 Thread ag0aep6g via Digitalmars-d-learn
On 03/25/2017 11:37 PM, zabruk70 wrote: union Union1 { align(1): byte[5] bytes5; struct { align(1): char char1; uint int1; } } void main () { import std.stdio: writefln; writefln("Union1.sizeof=%d", Union1.sizeof); //prints 8, not 5 } I'm not sure how the align stuff

union.sizeof

2017-03-25 Thread zabruk70 via Digitalmars-d-learn
//DMD 2.073.1 and latest 2.075.0-master-972eaed //Windows 7 32-bit union Union1 { align(1): byte[5] bytes5; struct { align(1): char char1; uint int1; } } void main () { import std.stdio: writefln; writefln("Union1.sizeof=%d", Union1.sizeof); //prints 8, not 5 } I expe

Re: 'fopen64 cannot be interpreted at compile time' for __gshared File

2017-03-25 Thread StarGrazer via Digitalmars-d-learn
On Saturday, 25 March 2017 at 16:46:00 UTC, crimaniak wrote: On Saturday, 25 March 2017 at 16:08:49 UTC, NotSpooky wrote: __gshared implies static,... Thanks! Confusing for me moment. try this: import std.stdio; void main() { import std.stdio; __gshared File f;

Re: recommend Git GUI client for Linux?

2017-03-25 Thread XavierAP via Digitalmars-d-learn
On Thursday, 2 March 2017 at 06:16:09 UTC, Patrick Schluter wrote: Here [1] is the official git page listing all GUI clients for different plartforms. I use GitExtensions[2] and I like it a lot. It works very well and all the complicated stuff can be done from the GUI interface and also from

Re: 'fopen64 cannot be interpreted at compile time' for __gshared File

2017-03-25 Thread crimaniak via Digitalmars-d-learn
On Saturday, 25 March 2017 at 16:08:49 UTC, NotSpooky wrote: __gshared implies static,... Thanks! Confusing for me moment.

Re: 'fopen64 cannot be interpreted at compile time' for __gshared File

2017-03-25 Thread NotSpooky via Digitalmars-d-learn
On Saturday, 25 March 2017 at 15:52:15 UTC, crimaniak wrote: Simple File test: void main() { import std.stdio; File f = File("test.txt", "w"); f.writeln("hello"); } All works as expected. Now let's add __gshared: void main() { import std.s

'fopen64 cannot be interpreted at compile time' for __gshared File

2017-03-25 Thread crimaniak via Digitalmars-d-learn
Simple File test: void main() { import std.stdio; File f = File("test.txt", "w"); f.writeln("hello"); } All works as expected. Now let's add __gshared: void main() { import std.stdio; __gshared File f = File("test.txt", "w");

Re: Exporting template function instances to C

2017-03-25 Thread data pulverizer via Digitalmars-d-learn
On Saturday, 25 March 2017 at 06:17:15 UTC, Nicholas Wilson wrote: On Saturday, 25 March 2017 at 02:21:33 UTC, data pulverizer wrote: Thanks a lot ... I was half joking playing with the name "mangling" but I appreciate your explanations and suggestions. This is the internet, I can't tell if yo