Re: DMD Fails with fPIC error

2014-06-17 Thread Reuben via Digitalmars-d-learn
On Sunday, 15 June 2014 at 09:08:10 UTC, Mike Wey wrote: On 06/14/2014 06:37 PM, Reuben wrote: It looks like the only difference is which version of Phobos we link. I think the reason for this might be that since my version of gcc is hardened, it uses -fPIE by default for linking. (http://wiki

Re: interface is interface

2014-06-17 Thread rumbu via Digitalmars-d-learn
On Tuesday, 17 June 2014 at 19:02:34 UTC, Pavel wrote: class A : B, C { override void test() {} override void test1() {} } If you swap the interfaces (class A: C, B), "a is b" will return false, but "a is c" will return true. Clearly, this is a bug. void main() { A a = new A()

C++'s "defaulted comparison operators" proposal

2014-06-17 Thread Ali Çehreli via Digitalmars-d-learn
Can you come up with a D library solution to the following C++11 proposal: http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2014/n3950.html The idea is to be able to have standard comparison behavior for structs without boilerplate. For example, if the ordering should consider all members

Re: External threads calling into D code

2014-06-17 Thread George Sapkin via Digitalmars-d-learn
On Wednesday, 18 June 2014 at 02:35:03 UTC, Ali Çehreli wrote: Without any experience on this topic, I suspect this is what you need: http://dlang.org/phobos/core_thread.html#.thread_attachThis Ali That was exactly what I needed. Thanks.

Re: Formatted read of tokens?

2014-06-17 Thread Jerry via Digitalmars-d-learn
"John Colvin" writes: > On Tuesday, 17 June 2014 at 13:16:38 UTC, Jerry wrote: >> "bearophile" writes: >> >>> Jerry: >>> If I do f.readf("%s %s", &l, &i); it fails if the whitespace is a tab. >>> >>> In you can use byLine, followed by a split, and then assignment of the

Re: When is a slice not a slice?

2014-06-17 Thread Jesse Phillips via Digitalmars-d-learn
On Thursday, 5 June 2014 at 19:45:59 UTC, Alix Pexton wrote: unittest { auto a = DataAndView(1); assert (sameTail(a.data, a.view)); enum b = DataAndView(1); assert (!sameTail(b.data, b.view)); } Just a request of presentation. Please make expected assertions:

Re: External threads calling into D code

2014-06-17 Thread Ali Çehreli via Digitalmars-d-learn
On 06/17/2014 06:43 PM, George Sapkin wrote: So, me and my threads again :) I have some threads being created by libuv using start_thread() from libpthread calling into D code. D code (after some help from this forum) has been properly shared and when called from D threads and tasks works correc

Re: D1: UTF8 char[] casting to wchar[] array cast misalignment ERROR

2014-06-17 Thread Jesse Phillips via Digitalmars-d-learn
On Tuesday, 17 June 2014 at 02:27:43 UTC, jicman wrote: Greetings! I have a bunch of files plain ASCII, UTF8 and UTF16 with and without BOM (Byte Order Mark). I had, "I thought", a nice way of figuring out what type of encoding the file was (ASCII, UTF8 or UTF16) when the BOM was missing, b

External threads calling into D code

2014-06-17 Thread George Sapkin via Digitalmars-d-learn
So, me and my threads again :) I have some threads being created by libuv using start_thread() from libpthread calling into D code. D code (after some help from this forum) has been properly shared and when called from D threads and tasks works correctly. However when called by libuv from out

Re: what is going on with cgcs.c:351?

2014-06-17 Thread Trass3r via Digitalmars-d-learn
I think it should be possible to run DustMite on some big project like phobos to actually search for such internal errors.

Re: interface is interface

2014-06-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tue, 17 Jun 2014 15:02:33 -0400, Pavel wrote: Hello! import std.stdio; interface I { } interface B : I { void test(); } interface C : I { void test1(); } class A : B, C { override void test() {} override void test1() {} } void main() { A a = new A

Re: How to define and use a custom comparison function

2014-06-17 Thread TheFlyingFiddle via Digitalmars-d-learn
On Tuesday, 17 June 2014 at 07:53:51 UTC, monarch_dodra wrote: On Tuesday, 17 June 2014 at 04:32:20 UTC, Jakob Ovrum wrote: On Monday, 16 June 2014 at 20:49:29 UTC, monarch_dodra wrote: MyCompare cmp(SortOrder.ASC, 10); This syntax is not valid D. It should be: auto cmp = MyCompare(SortO

interface is interface

2014-06-17 Thread Pavel via Digitalmars-d-learn
Hello! import std.stdio; interface I { } interface B : I { void test(); } interface C : I { void test1(); } class A : B, C { override void test() {} override void test1() {} } void main() { A a = new A(); I b = cast(B)a; I c = cast(C)a; w

Re: Working on a library: request for code review

2014-06-17 Thread Mike via Digitalmars-d-learn
Thanks, will work on fixes tonight. The current method will not detect an error when the image type is not mapped but a color map is present. At least I assume that is not a valid TGA file? A non-mapped image may contain a color map ;-0 it's simply discarded. As per your ideas return t

Re: Trying to sort shared data with a predicate causes 'unable to format shared objects'

2014-06-17 Thread Ali Çehreli via Digitalmars-d-learn
On 06/17/2014 11:17 AM, George Sapkin wrote: On Tuesday, 17 June 2014 at 17:18:36 UTC, Ali Çehreli wrote: Shared data can be accessed by more than one thread. Unless it is locked, other threads may see the array in an inconsistent state. Ali But that's a local copy of it, no? If it's not, wil

Re: Trying to sort shared data with a predicate causes 'unable to format shared objects'

2014-06-17 Thread George Sapkin via Digitalmars-d-learn
On Tuesday, 17 June 2014 at 17:18:36 UTC, Ali Çehreli wrote: Shared data can be accessed by more than one thread. Unless it is locked, other threads may see the array in an inconsistent state. Ali But that's a local copy of it, no? If it's not, will making a local copy solve this? The origi

Re: Trying to sort shared data with a predicate causes 'unable to format shared objects'

2014-06-17 Thread Ali Çehreli via Digitalmars-d-learn
On 06/17/2014 08:51 AM, George Sapkin wrote:> Does making an array copy with shared cast away make any sense? > > auto n = 10; > auto sharedData = new shared SomeClass[n]; > foreach (i; 0..n) sharedData[i] = new shared SomeClass(i); > > auto nonSharedData = cast(SomeClass[]) sharedData[0..$]; > a

Re: Trying to sort shared data with a predicate causes 'unable to format shared objects'

2014-06-17 Thread George Sapkin via Digitalmars-d-learn
Does making an array copy with shared cast away make any sense? auto n = 10; auto sharedData = new shared SomeClass[n]; foreach (i; 0..n) sharedData[i] = new shared SomeClass(i); auto nonSharedData = cast(SomeClass[]) sharedData[0..$]; auto sorted = sort!((a, b) => a.value < b.value)(nonSharedDa

Re: Trying to sort shared data with a predicate causes 'unable to format shared objects'

2014-06-17 Thread Andrew Edwards via Digitalmars-d-learn
On 6/17/14, 11:34 AM, George Sapkin wrote: On Tuesday, 17 June 2014 at 04:38:24 UTC, Ali Çehreli wrote: Good news: The code compiles with 2.066 after adding 'import std.algorithm;' :) Ali Thanks, but where can I get 2.066? It seems it's not going to be branched until June 30th. Is there any

Re: Trying to sort shared data with a predicate causes 'unable to format shared objects'

2014-06-17 Thread George Sapkin via Digitalmars-d-learn
On Tuesday, 17 June 2014 at 04:38:24 UTC, Ali Çehreli wrote: Good news: The code compiles with 2.066 after adding 'import std.algorithm;' :) Ali Thanks, but where can I get 2.066? It seems it's not going to be branched until June 30th. Is there any way to resolve this now with 2.065?

Re: Formatted read of tokens?

2014-06-17 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 17 June 2014 at 13:16:38 UTC, Jerry wrote: "bearophile" writes: Jerry: If I do f.readf("%s %s", &l, &i); it fails if the whitespace is a tab. In you can use byLine, followed by a split, and then assignment of the pieces, followed by to!int where necessary. I actually can'

Re: D1: UTF8 char[] casting to wchar[] array cast misalignment ERROR

2014-06-17 Thread jicman via Digitalmars-d-learn
On Tuesday, 17 June 2014 at 12:54:39 UTC, Marc Schütz wrote: On Tuesday, 17 June 2014 at 02:27:43 UTC, jicman wrote: Greetings! I have a bunch of files plain ASCII, UTF8 and UTF16 with and without BOM (Byte Order Mark). I had, "I thought", a nice way of figuring out what type of encoding th

Re: D1: UTF8 char[] casting to wchar[] array cast misalignment ERROR

2014-06-17 Thread jicman via Digitalmars-d-learn
On Tuesday, 17 June 2014 at 07:49:59 UTC, monarch_dodra wrote: On Tuesday, 17 June 2014 at 06:44:40 UTC, Jacob Carlborg wrote: On 17/06/14 04:27, jicman wrote: Greetings! I have a bunch of files plain ASCII, UTF8 and UTF16 with and without BOM (Byte Order Mark). I had, "I thought", a nice w

Re: D1: UTF8 char[] casting to wchar[] array cast misalignment ERROR

2014-06-17 Thread jicman via Digitalmars-d-learn
On Tuesday, 17 June 2014 at 06:44:40 UTC, Jacob Carlborg wrote: On 17/06/14 04:27, jicman wrote: Greetings! I have a bunch of files plain ASCII, UTF8 and UTF16 with and without BOM (Byte Order Mark). I had, "I thought", a nice way of figuring out what type of encoding the file was (ASCII, U

Re: Formatted read of tokens?

2014-06-17 Thread Jerry via Digitalmars-d-learn
"bearophile" writes: > Jerry: > >> If I do >> >> f.readf("%s %s", &l, &i); >> >> it fails if the whitespace is a tab. > > In you can use byLine, followed by a split, and then assignment of the pieces, > followed by to!int where necessary. I actually can't use byLine in this instance. I'm really

Re: Working on a library: request for code review

2014-06-17 Thread via Digitalmars-d-learn
On Monday, 16 June 2014 at 23:04:33 UTC, Rene Zwanenburg wrote: This one depends on taste, but these helpers can be eliminated by changing the Header definition a little. It's the same union / anonymous struct trick from the previous post, only this time with bitfields: http://dpaste.dzfl.pl/

Re: D1: UTF8 char[] casting to wchar[] array cast misalignment ERROR

2014-06-17 Thread via Digitalmars-d-learn
On Tuesday, 17 June 2014 at 02:27:43 UTC, jicman wrote: Greetings! I have a bunch of files plain ASCII, UTF8 and UTF16 with and without BOM (Byte Order Mark). I had, "I thought", a nice way of figuring out what type of encoding the file was (ASCII, UTF8 or UTF16) when the BOM was missing, b

DLLs with Cygwin don't work

2014-06-17 Thread Chris via Digitalmars-d-learn
The following: 1. created test C-dll in Cygwin (gcc -shared -o hello.dll hello.o) 2. used "implib.exe /s" to create .lib file 3. linked with D program "dmd test.d hello.lib" Compiles, program starts but begins to hang as soon as it calls the C function (which itself is never executed, no "hello

Re: Formatted read of tokens?

2014-06-17 Thread bearophile via Digitalmars-d-learn
Jerry: If I do f.readf("%s %s", &l, &i); it fails if the whitespace is a tab. In you can use byLine, followed by a split, and then assignment of the pieces, followed by to!int where necessary. Bye, bearophile

Re: How to define and use a custom comparison function

2014-06-17 Thread monarch_dodra via Digitalmars-d-learn
On Tuesday, 17 June 2014 at 04:32:20 UTC, Jakob Ovrum wrote: On Monday, 16 June 2014 at 20:49:29 UTC, monarch_dodra wrote: MyCompare cmp(SortOrder.ASC, 10); This syntax is not valid D. It should be: auto cmp = MyCompare(SortOrder,ASC, 10); Well, techincally, the *syntax* is valid. If "

Re: D1: UTF8 char[] casting to wchar[] array cast misalignment ERROR

2014-06-17 Thread monarch_dodra via Digitalmars-d-learn
On Tuesday, 17 June 2014 at 06:44:40 UTC, Jacob Carlborg wrote: On 17/06/14 04:27, jicman wrote: Greetings! I have a bunch of files plain ASCII, UTF8 and UTF16 with and without BOM (Byte Order Mark). I had, "I thought", a nice way of figuring out what type of encoding the file was (ASCII, U

Formatted read of tokens?

2014-06-17 Thread Jerry via Digitalmars-d-learn
Hi all, I'm porting some C++ code into D that uses istream to read lines like label 3 where there can spaces or tabs between the 2 fields. In c++, this is: string l; int i; istr >> l >> i; What's the equivalent in D? It appears that D formatted read for strings grabs everything up to a newli