Re: Mingling string and identifier namespaces in nested extern(C++) decls

2019-09-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, September 7, 2019 2:18:40 PM MDT Jonathan M Davis via Digitalmars-d-learn wrote: > On Saturday, September 7, 2019 8:53:54 AM MDT Max Samukha via > Digitalmars-d- > learn wrote: > > extern(C++, "ns1") { > > > > extern(C++, ns2) { > > > > extern(C++, "ns3") { > > > >

Newbie linker errors - still missing _fltused _tls_index _tls_used localtime tzset mainCRTStartup

2019-09-07 Thread malpropism via Digitalmars-d-learn
I just ported my Java application to D, got it to compile, but not to link. I'm using Windows 10 64 bit, DMD 2.088.0 , Visual D 0.50.1. This would be a C/C++ project in Visual Studio with only D code. With my first attempt, I'm missing 65 externals, 328 errors. I added these two files

Re: Should an 'extern(C++, "ns"):' override previous ones in the same scope?

2019-09-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, September 7, 2019 3:40:58 PM MDT Exil via Digitalmars-d-learn wrote: > On Saturday, 7 September 2019 at 17:22:07 UTC, Jonathan M Davis > > wrote: > > @safe: > > @system: > > > > then @system overrides @safe. > > Just to add onto this, you can't do: > > @safe @system void foo();

Re: Should an 'extern(C++, "ns"):' override previous ones in the same scope?

2019-09-07 Thread Exil via Digitalmars-d-learn
On Saturday, 7 September 2019 at 17:22:07 UTC, Jonathan M Davis wrote: @safe: @system: then @system overrides @safe. Just to add onto this, you can't do: @safe @system void foo(); // error but you can do: extern(C++, ns1) extern(C++, ns2) void foo(); // ok

Re: Should an 'extern(C++, "ns"):' override previous ones in the same scope?

2019-09-07 Thread Exil via Digitalmars-d-learn
On Saturday, 7 September 2019 at 17:22:07 UTC, Jonathan M Davis wrote: makes no sense whatsoever IMHO. IIRC, this version of extern(C++) didn't go through the DIP process and was simply added via a PR. The original extern(C++) worked the same way. Since it was implemented in v2.066.0 by the

Re: Mingling string and identifier namespaces in nested extern(C++) decls

2019-09-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, September 7, 2019 8:53:54 AM MDT Max Samukha via Digitalmars-d- learn wrote: > extern(C++, "ns1") { > extern(C++, ns2) { > extern(C++, "ns3") { > extern(C++, ns4) { > void foo(); > } > } > } > } > > pragma(msg, foo.mangleof); //

Re: Should an 'extern(C++, "ns"):' override previous ones in the same scope?

2019-09-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, September 7, 2019 9:15:44 AM MDT Max Samukha via Digitalmars-d- learn wrote: > extern(C++, "ns1"): > extern(C++, "ns2"): // Not in nested scope. Should it supersede? > void foo(); > > pragma(msg, foo.mangleof); // _ZN3ns13ns23fooEv instead of > expected _ZN3ns23fooEv > > Is that by

Should an 'extern(C++, "ns"):' override previous ones in the same scope?

2019-09-07 Thread Max Samukha via Digitalmars-d-learn
extern(C++, "ns1"): extern(C++, "ns2"): // Not in nested scope. Should it supersede? void foo(); pragma(msg, foo.mangleof); // _ZN3ns13ns23fooEv instead of expected _ZN3ns23fooEv Is that by design?

Mingling string and identifier namespaces in nested extern(C++) decls

2019-09-07 Thread Max Samukha via Digitalmars-d-learn
extern(C++, "ns1") { extern(C++, ns2) { extern(C++, "ns3") { extern(C++, ns4) { void foo(); } } } } pragma(msg, foo.mangleof); // _ZN3ns23ns43ns13ns33fooEv That

Re: Why are extern(C/C++) definitions and references mangled differently in separately compiled modules?

2019-09-07 Thread Max Samukha via Digitalmars-d-learn
On Saturday, 7 September 2019 at 13:01:38 UTC, Jacob Carlborg wrote: On 2019-09-06 21:03, Max Samukha wrote: Is there any practical use of having identically named .d and .di alongside? Same as in C/C++. This allows you to have a header file if you want to distribute a closed source

Re: C++ vs D: Default param values and struct to array casting

2019-09-07 Thread Jacob Carlborg via Digitalmars-d-learn
On 2019-09-06 11:14, Andrew Edwards wrote: C++ allows the for following: struct Demo { float a, b, c, d; Demo() { a = b = c = d = 0.0f; } Demo(float _a, float _b, float _c, float _d) {     a = _a;     b = _b;     c = _c;     d = _d; } float 

Re: Why are extern(C/C++) definitions and references mangled differently in separately compiled modules?

2019-09-07 Thread Jacob Carlborg via Digitalmars-d-learn
On 2019-09-06 21:03, Max Samukha wrote: Is there any practical use of having identically named .d and .di alongside? Same as in C/C++. This allows you to have a header file if you want to distribute a closed source library. -- /Jacob Carlborg

Re: Interfacing to C++: Cannot access value from namespace

2019-09-07 Thread Andrew Edwards via Digitalmars-d-learn
On Saturday, 7 September 2019 at 12:39:25 UTC, Ali Çehreli wrote: On 09/07/2019 03:26 AM, Andrew Edwards wrote: > [1] I did not declare any of the other member variables from the struct, > don't know if this is a source of the problem. Yes, it definitely is a problem. The members are accessed

Re: Interfacing to C++: Cannot access value from namespace

2019-09-07 Thread Ali Çehreli via Digitalmars-d-learn
On 09/07/2019 03:26 AM, Andrew Edwards wrote: > [1] I did not declare any of the other member variables from the struct, > don't know if this is a source of the problem. Yes, it definitely is a problem. The members are accessed as byte offsets into their objects. Without defining the other

Re: Interfacing to C++: Cannot access value from namespace

2019-09-07 Thread Andrew Edwards via Digitalmars-d-learn
On Saturday, 7 September 2019 at 12:30:53 UTC, Andrew Edwards wrote: On Saturday, 7 September 2019 at 12:24:49 UTC, Ali Çehreli wrote: On 09/07/2019 03:26 AM, Andrew Edwards wrote: > float continuallyUpdatedValue; > float continuallyChangingValue; // [1] They mean the same thing for

Re: Interfacing to C++: Cannot access value from namespace

2019-09-07 Thread Andrew Edwards via Digitalmars-d-learn
On Saturday, 7 September 2019 at 12:24:49 UTC, Ali Çehreli wrote: On 09/07/2019 03:26 AM, Andrew Edwards wrote: > float continuallyUpdatedValue; > float continuallyChangingValue; // [1] They mean the same thing for an English speaker but compilers don't know that (yet?). :) Ali

Re: Interfacing to C++: Cannot access value from namespace

2019-09-07 Thread Ali Çehreli via Digitalmars-d-learn
On 09/07/2019 03:26 AM, Andrew Edwards wrote: > float continuallyUpdatedValue; > float continuallyChangingValue; // [1] They mean the same thing for an English speaker but compilers don't know that (yet?). :) Ali

Re: C++ vs D: Default param values and struct to array casting

2019-09-07 Thread Maximillian via Digitalmars-d-learn
On Saturday, 7 September 2019 at 11:22:09 UTC, Maximillian wrote: Please could you tell what "goto case;" do here? I see now "fall-through" [1]. To be honest I like this feature in C and I was sad it didn't work in D, at least now I know how to solve it. :) Max. [1]

Re: C++ vs D: Default param values and struct to array casting

2019-09-07 Thread Maximillian via Digitalmars-d-learn
On Friday, 6 September 2019 at 18:31:29 UTC, Ali Çehreli wrote: ... void enforceMemberWiseEquality(Demo d, const(float)[] values) { switch (values.length) { case 4: assert(d.d == values[3]); goto case; case 3: assert(d.c == values[2]); goto case;

Interfacing to C++: Cannot access value from namespace

2019-09-07 Thread Andrew Edwards via Digitalmars-d-learn
I'm running into the following issue when attempting to interface with C++: // C++ namespace MySpace { MyType& GetData(); } struct MyType { // ... float continuallyUpdatedValue; // ... }; // call site MySpace::GetData().continuallyUpdatedValue; // D extern

Re: C++ vs D: Default param values and struct to array casting

2019-09-07 Thread Andrew Edwards via Digitalmars-d-learn
On Friday, 6 September 2019 at 18:31:29 UTC, Ali Çehreli wrote: On 09/06/2019 02:14 AM, Andrew Edwards wrote: > I'm seeking some pointers on how to define these in D Here is my attempt: Ali, this is awesome. It solves all 4 problems in on shot. I definitely don't intend on using the

Re: Function Arguments with Multiple Types

2019-09-07 Thread Bert via Digitalmars-d-learn
On Friday, 6 September 2019 at 20:02:35 UTC, Bob4 wrote: Hi, I'm coming from a background in Python, without a lot of experience in statically typed languages, and I'm struggling to see how to make a certain function in D. This is what I have in Python: ``` from typing import Union Number