Re: call Pascal DLL functions from D

2017-10-24 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 25 October 2017 at 03:12:56 UTC, Oleg B wrote: Hello. I have DLL written on Pascal and "headers" for use it (types and functions signatures definitions). How I can port "headers" to D? Calling convention is `stdcall` (`extern (Windows)` for D), arguments of some functions is

Re: call Pascal DLL functions from D

2017-10-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 25 October 2017 at 03:12:56 UTC, Oleg B wrote: Calling convention is `stdcall` (`extern (Windows)` for D), arguments of some functions is structs of structs and etc with static array fields: Fun fact, D has extern(Pascal): https://dlang.org/spec/attribute.html#linkage I

call Pascal DLL functions from D

2017-10-24 Thread Oleg B via Digitalmars-d-learn
Hello. I have DLL written on Pascal and "headers" for use it (types and functions signatures definitions). How I can port "headers" to D? Calling convention is `stdcall` (`extern (Windows)` for D), arguments of some functions is structs of structs and etc with static array fields:

Re: Getting a safe path for a temporary file

2017-10-24 Thread Ali Çehreli via Digitalmars-d-learn
On 10/22/2017 06:41 PM, Shriramana Sharma wrote: > On Sunday, 22 October 2017 at 15:21:37 UTC, Shriramana Sharma wrote: >> For my program right now I'm using a souped-up version using a static >> array: >> >> char[20] name = "/tmp/XX"; Literal strings have a '\0' attached, which does not

Re: DMD Callstacks

2017-10-24 Thread user1234 via Digitalmars-d-learn
On Tuesday, 24 October 2017 at 06:49:37 UTC, abad wrote: On Monday, 23 October 2017 at 12:41:09 UTC, Márcio Martins wrote: What is everyone doing to get proper file name and line number info for callstacks with DMD? addr2line just gives me ??:0 You could try compiling with the

Re: Address problem

2017-10-24 Thread Ali Çehreli via Digitalmars-d-learn
On 10/24/2017 10:47 AM, Gheorghe Gabriel wrote: > writeln(&_i); That's the address of the local variable _i. You can think of class (and interface) variables as pointers to class objects. > I need that I["s"] to have the same address like c. The way to get the address of the

Re: writeln double precision

2017-10-24 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Oct 24, 2017 at 04:59:04PM +, jmh530 via Digitalmars-d-learn wrote: > On Tuesday, 24 October 2017 at 16:18:03 UTC, H. S. Teoh wrote: > > > > I have never seen a programming language in which dividing two > > integers yields a float or double. Either numbers default to a > > floating

Address problem

2017-10-24 Thread Gheorghe Gabriel via Digitalmars-d-learn
Hi, --- interface I { } I[string] i; class C : I { this() { i["s"] = this; foreach (_i; i) { writeln(&_i); } foreach (ref _i; i) { writeln(&_i); } } } void main() { C c =

Re: writeln double precision

2017-10-24 Thread Ali Çehreli via Digitalmars-d-learn
On 10/24/2017 09:59 AM, Arun Chandrasekaran wrote: >>> On Monday, 23 October 2017 at 18:08:43 UTC, Ali Çehreli wrote: >>> > The rule is that every expression has a type and 22/7 is int. > I'm just questioning the reasoning behind why D does it this way and if > it is for compatibility or if

Re: writeln double precision

2017-10-24 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 24 October 2017 at 16:18:03 UTC, H. S. Teoh wrote: I have never seen a programming language in which dividing two integers yields a float or double. Either numbers default to a floating point type, in which case you begin with floats in the first place, or division is integer

Re: writeln double precision

2017-10-24 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Tuesday, 24 October 2017 at 16:18:03 UTC, H. S. Teoh wrote: On Tue, Oct 24, 2017 at 10:02:11AM +, Arun Chandrasekaran via Digitalmars-d-learn wrote: On Monday, 23 October 2017 at 18:08:43 UTC, Ali Çehreli wrote: > On 10/23/2017 07:22 AM, Arun Chandrasekaran wrote: > > [...] > The rule is

Re: writeln double precision

2017-10-24 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Oct 24, 2017 at 10:02:11AM +, Arun Chandrasekaran via Digitalmars-d-learn wrote: > On Monday, 23 October 2017 at 18:08:43 UTC, Ali Çehreli wrote: > > On 10/23/2017 07:22 AM, Arun Chandrasekaran wrote: > > > [...] > > The rule is that every expression has a type and 22/7 is int. > >

Re: Disabled and enabled copy constructors and .dup

2017-10-24 Thread Biotronic via Digitalmars-d-learn
On Tuesday, 24 October 2017 at 11:37:42 UTC, Per Nordlöw wrote: On Tuesday, 24 October 2017 at 07:56:34 UTC, Biotronic wrote: struct SuppressPostblit(T) { // Disguise T as a humble array. private ubyte[T.sizeof] _payload; ... A bit too hackish for my taste, but does the job still.

Re: Disabled and enabled copy constructors and .dup

2017-10-24 Thread Per Nordlöw via Digitalmars-d-learn
On Tuesday, 24 October 2017 at 07:56:34 UTC, Biotronic wrote: struct SuppressPostblit(T) { // Disguise T as a humble array. private ubyte[T.sizeof] _payload; ... A bit too hackish for my taste, but does the job still. Thanks.

Re: writeln double precision

2017-10-24 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Monday, 23 October 2017 at 18:08:43 UTC, Ali Çehreli wrote: On 10/23/2017 07:22 AM, Arun Chandrasekaran wrote: > [...] The rule is that every expression has a type and 22/7 is int. Thanks Ali. Is this for backward compatibility with C? Because, if there is a division, a

Re: Disabled and enabled copy constructors and .dup

2017-10-24 Thread Biotronic via Digitalmars-d-learn
On Tuesday, 24 October 2017 at 07:33:43 UTC, Per Nordlöw wrote: If I have a `struct X` (container in my case) with disabled copying (postblit) and instead a .dup property, is it somehow possible, unsafe or not, to have `X` as a member of another `struct Y` with an enabled copy constructor

Disabled and enabled copy constructors and .dup

2017-10-24 Thread Per Nordlöw via Digitalmars-d-learn
If I have a `struct X` (container in my case) with disabled copying (postblit) and instead a .dup property, is it somehow possible, unsafe or not, to have `X` as a member of another `struct Y` with an enabled copy constructor which calls `X.dup`?

Re: DMD Callstacks

2017-10-24 Thread abad via Digitalmars-d-learn
On Monday, 23 October 2017 at 12:41:09 UTC, Márcio Martins wrote: What is everyone doing to get proper file name and line number info for callstacks with DMD? addr2line just gives me ??:0 You could try compiling with the -debug-switch. Of course if this turns out to be the fix, it doesn't