Re: Extern C and Symbol Mangling

2017-05-26 Thread MGW via Digitalmars-d-learn
On Friday, 26 May 2017 at 12:49:27 UTC, Oleksii wrote: Hi, Call methods and property C++ from D. Interface C++ and D and their interaction. https://pp.userapi.com/c636630/v636630885/4657a/07wCn5hbHHo.jpg https://www.youtube.com/watch?v=HTgJaRRfLPk

Re: binding to C++

2017-05-26 Thread Mike B Johnson via Digitalmars-d-learn
On Friday, 26 May 2017 at 15:17:08 UTC, drug wrote: Trying to bind to cpp code I stop at some moment having undefined reference to some cpp function. But objdump -Ct cpplibrary.so shows me that this cpp function exists in the library. linker message about cpp function is _identical_ to

Re: binding to C++

2017-05-26 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 26 May 2017 at 15:17:08 UTC, drug wrote: Trying to bind to cpp code I stop at some moment having undefined reference to some cpp function. But objdump -Ct cpplibrary.so shows me that this cpp function exists in the library. linker message about cpp function is _identical_ to

Re: Out of memory error (even when using destroy())

2017-05-26 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, May 26, 2017 at 06:06:42PM +, Mike B Johnson via Digitalmars-d-learn wrote: > On Friday, 26 May 2017 at 14:05:34 UTC, ag0aep6g wrote: > > On 05/26/2017 10:15 AM, realhet wrote: > > > But hey, the GC knows that is should not search for any pointers > > > in those large blocks. And the

Re: Out of memory error (even when using destroy())

2017-05-26 Thread Stanislav Blinov via Digitalmars-d-learn
On Friday, 26 May 2017 at 18:06:42 UTC, Mike B Johnson wrote: On Friday, 26 May 2017 at 14:05:34 UTC, ag0aep6g wrote: On 05/26/2017 10:15 AM, realhet wrote: But hey, the GC knows that is should not search for any pointers in those large blocks. And the buffer is full of 0-s at the start, so

Re: Out of memory error (even when using destroy())

2017-05-26 Thread Mike B Johnson via Digitalmars-d-learn
On Friday, 26 May 2017 at 14:05:34 UTC, ag0aep6g wrote: On 05/26/2017 10:15 AM, realhet wrote: But hey, the GC knows that is should not search for any pointers in those large blocks. And the buffer is full of 0-s at the start, so there can't be any 'false pointers' in it. And I think the GC

Re: The syntax of sort and templates

2017-05-26 Thread Ola Fosheim Grostad via Digitalmars-d-learn
On Friday, 26 May 2017 at 15:49:06 UTC, Ali Çehreli wrote: For example, Stroustrup has the article "Learning Standard C++ as a New Language"[1]. It compares sorting performance of C to C++ in section 3, "Efficiency". With those old C and C++ compilers he used (in May 1999), C++ was 1.74 to

Re: The syntax of sort and templates

2017-05-26 Thread Ali Çehreli via Digitalmars-d-learn
On 05/26/2017 05:10 AM, Patrick Schluter wrote: > in C, where sorting is done via the qsort() function. The comparison > function must be provided by a function pointer. This means that the > qsort function must call a function for doing even the simplest > comparison. For example, Stroustrup

binding to C++

2017-05-26 Thread drug via Digitalmars-d-learn
Trying to bind to cpp code I stop at some moment having undefined reference to some cpp function. But objdump -Ct cpplibrary.so shows me that this cpp function exists in the library. linker message about cpp function is _identical_ to objdump message so I don't know where is the difference.

Re: The syntax of sort and templates

2017-05-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 26 May 2017 at 11:05:37 UTC, Gary Willoughby wrote: The exclamation mark here is not a binary operator, it's used in D templates to define where compile-time parameters are. It actually is a binary operator, its left-hand-side is a template and its right-hand-side is a template

Re: Out of memory error (even when using destroy())

2017-05-26 Thread ag0aep6g via Digitalmars-d-learn
On 05/26/2017 10:15 AM, realhet wrote: But hey, the GC knows that is should not search for any pointers in those large blocks. And the buffer is full of 0-s at the start, so there can't be any 'false pointers' in it. And I think the GC will not search in it either. The issue is not that the

Re: Extern C and Symbol Mangling

2017-05-26 Thread Oleksii via Digitalmars-d-learn
On Friday, 26 May 2017 at 12:51:20 UTC, Stanislav Blinov wrote: On Friday, 26 May 2017 at 12:49:27 UTC, Oleksii wrote: Hi, I'm trying to link against a DLL which exports a bunch of C functions. The issue is: C symbols do not have underscore prefix in Windows, but DMD sticks underscore in

Re: Extern C and Symbol Mangling

2017-05-26 Thread Stanislav Blinov via Digitalmars-d-learn
On Friday, 26 May 2017 at 12:49:27 UTC, Oleksii wrote: Hi, I'm trying to link against a DLL which exports a bunch of C functions. The issue is: C symbols do not have underscore prefix in Windows, but DMD sticks underscore in front of the symbol name. For example: `extern(C) void Foo()`

Extern C and Symbol Mangling

2017-05-26 Thread Oleksii via Digitalmars-d-learn
Hi, I'm trying to link against a DLL which exports a bunch of C functions. The issue is: C symbols do not have underscore prefix in Windows, but DMD sticks underscore in front of the symbol name. For example: `extern(C) void Foo()` becomes `_Foo`. Is there a way to disable that underscore?

Re: Get date at compile time

2017-05-26 Thread kdevel via Digitalmars-d-learn
On Saturday, 1 October 2016 at 15:00:29 UTC, pineapple wrote: Though I don't currently have any need for this feature I'd imagine that if I did I'd want the time in UTC, not locally You may invoke the compiler with TZ= prepended. (Linux)

Re: The syntax of sort and templates

2017-05-26 Thread Patrick Schluter via Digitalmars-d-learn
On Friday, 26 May 2017 at 09:59:26 UTC, zakk wrote: Hello everyone, I just started using D and I am a bit puzzled by the syntax of the sort function is std.algorithm.sorting, which is sort!(comparingFunction)(list) where comparingFunction is often a lambda expression. For instance in the

Re: The syntax of sort and templates

2017-05-26 Thread Stanislav Blinov via Digitalmars-d-learn
On Friday, 26 May 2017 at 11:27:19 UTC, zakk wrote: I have a followup question: my background is C and in Wolfram Mathematica, so my knowledge of templates is limited to trivial examples in C++, like: template const T& min(const T& lhs, const T& rhs) { return lhs < rhs ? lhs : rhs; }

Re: The syntax of sort and templates

2017-05-26 Thread nkm1 via Digitalmars-d-learn
On Friday, 26 May 2017 at 11:27:19 UTC, zakk wrote: I have a followup question: my background is C and in Wolfram Mathematica, so my knowledge of templates is limited to trivial examples in C++... It seems to me that when programming in D templates are something more powerful Even in C++

Re: The syntax of sort and templates

2017-05-26 Thread zakk via Digitalmars-d-learn
On Friday, 26 May 2017 at 11:18:44 UTC, Stanislav Blinov wrote: On Friday, 26 May 2017 at 09:59:26 UTC, zakk wrote: Hello everyone, I just started using D and I am a bit puzzled by the syntax of the sort function is std.algorithm.sorting, which is sort!(comparingFunction)(list) where

Re: The syntax of sort and templates

2017-05-26 Thread Mike Parker via Digitalmars-d-learn
On Friday, 26 May 2017 at 09:59:26 UTC, zakk wrote: My questions are: 1) Why is D making using of the binary ! operator, which as far as I understand introduces a template? The ! operator *instantiates* a template. Whenever you need to specify compile-time arguments to match the template

Re: The syntax of sort and templates

2017-05-26 Thread Stanislav Blinov via Digitalmars-d-learn
On Friday, 26 May 2017 at 09:59:26 UTC, zakk wrote: Hello everyone, I just started using D and I am a bit puzzled by the syntax of the sort function is std.algorithm.sorting, which is sort!(comparingFunction)(list) where comparingFunction is often a lambda expression. For instance in the

Re: The syntax of sort and templates

2017-05-26 Thread Gary Willoughby via Digitalmars-d-learn
On Friday, 26 May 2017 at 09:59:26 UTC, zakk wrote: 1) Why is D making using of the binary ! operator, which as far as I understand introduces a template? The exclamation mark here is not a binary operator, it's used in D templates to define where compile-time parameters are. 2) Why is a

The syntax of sort and templates

2017-05-26 Thread zakk via Digitalmars-d-learn
Hello everyone, I just started using D and I am a bit puzzled by the syntax of the sort function is std.algorithm.sorting, which is sort!(comparingFunction)(list) where comparingFunction is often a lambda expression. For instance in the Wolfram Language the equivalent function is

Re: Out of memory error (even when using destroy())

2017-05-26 Thread realhet via Digitalmars-d-learn
Jordan Wilson wrote: This I think achieves the spirit of your code, but without the memory exception: ubyte[] st; foreach(i; 0..2000){ writeln(i); st.length=500_000_000; // auto = new ubyte[500_000_000]; st.length=0; // destory(st) st.assumeSafeAppend; //

Re: Out of memory error (even when using destroy())

2017-05-26 Thread Guillaume Piolat via Digitalmars-d-learn
On Friday, 26 May 2017 at 08:15:49 UTC, realhet wrote: 64bit is not a solution because I need to produce a 32bit dll, and I also wanna use 32bit asm objs. The total 2GB amount of memory is more than enough for the problem. My program have to produce 300..500 MB of continuous data frequently.

Re: Out of memory error (even when using destroy())

2017-05-26 Thread Jordan Wilson via Digitalmars-d-learn
On Friday, 26 May 2017 at 06:31:49 UTC, realhet wrote: Hi, I'm kinda new to the D language and I love it already. :D So far I haven't got any serious problems but this one seems like beyond me. import std.stdio; void main(){ foreach(i; 0..2000){ writeln(i); auto st = new

Re: Out of memory error (even when using destroy())

2017-05-26 Thread rikki cattermole via Digitalmars-d-learn
On 26/05/2017 9:15 AM, realhet wrote: Thanks for the answer! But hey, the GC knows that is should not search for any pointers in those large blocks. And the buffer is full of 0-s at the start, so there can't be any 'false pointers' in it. And I think the GC will not search in it either. The

Re: Out of memory error (even when using destroy())

2017-05-26 Thread realhet via Digitalmars-d-learn
Thanks for the answer! But hey, the GC knows that is should not search for any pointers in those large blocks. And the buffer is full of 0-s at the start, so there can't be any 'false pointers' in it. And I think the GC will not search in it either. The only reference to the buffer is 'st'

Re: Out of memory error (even when using destroy())

2017-05-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, May 26, 2017 06:31:49 realhet via Digitalmars-d-learn wrote: > Hi, > > I'm kinda new to the D language and I love it already. :D So far > I haven't got any serious problems but this one seems like beyond > me. > > import std.stdio; > void main(){ > foreach(i; 0..2000){ >

Out of memory error (even when using destroy())

2017-05-26 Thread realhet via Digitalmars-d-learn
Hi, I'm kinda new to the D language and I love it already. :D So far I haven't got any serious problems but this one seems like beyond me. import std.stdio; void main(){ foreach(i; 0..2000){ writeln(i); auto st = new ubyte[500_000_000]; destroy(st); //<-this

Re: Sudoku Py / C++11 / D?

2017-05-26 Thread Era Scarecrow via Digitalmars-d-learn
On Wednesday, 15 August 2012 at 20:13:10 UTC, Era Scarecrow wrote: On Wednesday, 15 August 2012 at 15:39:26 UTC, ixid wrote: Could you supply your code? Which one are you using as the hardest? If you're solving the 1400 second one in 12 seconds that's very impressive, I can't get it below 240