Re: Why can't we use strings in C++ methods?

2023-11-04 Thread Dadoum via Digitalmars-d-learn
On Saturday, 4 November 2023 at 14:33:56 UTC, Basile B. wrote: [...] Now there is still the question whether the `extern(C)` code will work as expected or not. So with few patches could we make it work? DMD can write the C++ function prototype (as it does it with `extern (C)`) and then

Re: Why can't we use strings in C++ methods?

2023-11-04 Thread Dadoum via Digitalmars-d-learn
On Saturday, 4 November 2023 at 14:21:49 UTC, Paul Backus wrote: [...] `extern(C++)` functions use C++ name mangling, which includes the types of the parameters in the mangled name. However, since C++ does not have a built-in slice type like D's `T[]`, there is no valid C++ mangling for a D

Re: Why can't we use strings in C++ methods?

2023-11-04 Thread Dadoum via Digitalmars-d-learn
On Saturday, 4 November 2023 at 13:45:56 UTC, Emmanuel Danso Nyarko wrote: [...] There is a syntax disagreement here that's why the D compiler is instantly stopping you from doing any symbol generated interaction with string in C++ interop. C++ doesn't know 'string' and C++ mangles with

Re: Why can't we use strings in C++ methods?

2023-11-04 Thread Dadoum via Digitalmars-d-learn
On Saturday, 4 November 2023 at 12:01:11 UTC, Emmanuel Danso Nyarko wrote: [...] So C-strings are just an array of characters that are governed by simple functions and D strings also defined the same. So you could see that D strings are possibly built on the architecture of C strings. In

Re: Why can't we use strings in C++ methods?

2023-11-04 Thread Dadoum via Digitalmars-d-learn
On Saturday, 4 November 2023 at 12:07:12 UTC, Imperatorn wrote: [...] We can just assume what you're doing on the C++-side. Are you using std::string? You could try as a pointer + length and it might work, but without seeing your complete code it's quite hard to know what you want to do.

Re: Why can't we use strings in C++ methods?

2023-11-04 Thread Dadoum via Digitalmars-d-learn
On Saturday, 4 November 2023 at 12:21:45 UTC, Johan wrote: On Saturday, 4 November 2023 at 12:01:11 UTC, Emmanuel Danso Nyarko wrote: On Saturday, 4 November 2023 at 11:18:02 UTC, Dadoum wrote: ```d extern (C) void hello(string arg) { import std.stdio; writeln(arg); } ``` Compiles

Re: Why can't we use strings in C++ methods?

2023-11-04 Thread Dadoum via Digitalmars-d-learn
On Saturday, 4 November 2023 at 10:08:20 UTC, Imperatorn wrote: On Saturday, 4 November 2023 at 03:00:49 UTC, Dadoum wrote: I was wondering why C++ linkage forbids strings as arguments while we can with the C one. With C linkage, it's translated to a template that's defined in the

Why can't we use strings in C++ methods?

2023-11-03 Thread Dadoum via Digitalmars-d-learn
I was wondering why C++ linkage forbids strings as arguments while we can with the C one. With C linkage, it's translated to a template that's defined in the automatically generated header, but it just doesn't compile in C++.

Re: A Programmer's Dilema: juggling with C, BetterC, D, Macros and Cross Compiling, etc.

2023-05-01 Thread Dadoum via Digitalmars-d-learn
On Sunday, 30 April 2023 at 17:51:15 UTC, Eric P626 wrote: But how is this possible in a cross-compiling context. I am not sure if I can do that with the D language either as pure D or better C. DMD does not seem to offer cross compiling. GDC can compile better C, but not sure mingw can

Re: I like dlang but i don't like dub

2022-03-21 Thread Dadoum via Digitalmars-d-learn
On Friday, 18 March 2022 at 04:13:36 UTC, Alain De Vos wrote: Dlang includes some good ideas. But dub pulls in so much stuff. Too much for me. I like things which are clean,lean,little,small. But when i use dub it links with so many libraries. Are they really needed ? And how do you compare to