Re: Creating Libraries Callable from C

2014-04-26 Thread Rémy Mouëza via Digitalmars-d-learn
It is possible to write a D library useable from C. However, we may not be able to hide the fact that the library has been written in D. You must first export some D function you want to use from C, using extern (C) declaration. Then declare them in your C program or headers. You will also

Re: Capture parameter identifier name in a template?

2014-08-14 Thread Rémy Mouëza via Digitalmars-d-learn
Using __traits (identifier, ...) and a template alias seems to work for me: import std.stdio; /// Two kinds of enums: /// A named enum. enum VmParams { OBJ_MIN_CAP, PROTO_SLOT_IDX, FPTR_SLOT_IDX, } /// An anonymous one. enum { ATTR_CONFIGURABLE = 3, ATTR_WRITABLE,

Re: Capture parameter identifier name in a template?

2014-08-14 Thread Rémy Mouëza via Digitalmars-d-learn
I have just checked it and yes, it works with a constant that is not an enum: `const int FOO` defined in the module namespace or `static int BAR` defined in the dummy Vm class. On 08/14/2014 02:08 PM, Maxime Chevalier-Boisvert wrote: Thanks. Does it also work with a constant that's not an

Re: extern (c++) std::function?

2014-08-15 Thread Rémy Mouëza via Digitalmars-d-learn
You'll certainly have to make a C++ wrapper. However, a delegate being implemented as a struct containing a context pointer and a function, you can get some degree of interoperability between C++ and D (BUT note that it is an undocumented implementation detail subject to change without notice

Re: Tango Problems..

2014-08-31 Thread Rémy Mouëza via Digitalmars-d-learn
From what I understand in the error message, the linker cannot find a druntime function: void core.stdc.stdarg.va_end(void*). I would advise to check that the druntime lib is in the import path. In your the dmd repository, you should have a dmd.conf file containing something like:

Re: Tango Problems..

2014-08-31 Thread Rémy Mouëza via Digitalmars-d-learn
I have checked my ldc installation: the druntime library is located in ldc2-0.12.0-linux-x86/x86/libdruntime-ldc.a You should also add a some extra flags like: -L-L/path/to/ldc/lib/architecture -L-Ldruntime-ldc . On 08/31/2014 05:52 PM, seany wrote: I am linking against tango ldc

Re: Tango Problems..

2014-08-31 Thread Rémy Mouëza via Digitalmars-d-learn
Have you tried something like this: find /lib /usr/lib* /usr/local/lib* -name \*.a | grep -i druntime or a simple: locate druntime ? On 08/31/2014 10:50 PM, seany wrote: On Sunday, 31 August 2014 at 20:40:06 UTC, Rémy Mouëza wrote: -L-L/path/to/ldc/lib/architecture -L-Ldruntime-ldc .

Re: Tango Problems..

2014-08-31 Thread Rémy Mouëza via Digitalmars-d-learn
In case you don't find any druntime library, try to see if the missing symbol is in the libphobos2.a file (you'll first have to identify the directory where phobos is located): $ nm libphobos2.a | ddemangle | grep stdc | grep va_end T nothrow void

Re: Tango Problems..

2014-08-31 Thread Rémy Mouëza via Digitalmars-d-learn
I suggest to try linking with both phobos and tango. Only the druntime functions contained in phobos should be used by the linker (if I am correct). Otherwise, did you take a look at code.dlang.org? Depending on your needs, there might be a dub package you could use to fill in for the

Re: how to catch D Throwables (or exceptions) from C++?

2016-12-01 Thread Rémy Mouëza via Digitalmars-d-learn
On Thursday, 1 December 2016 at 01:58:13 UTC, Timothee Cour wrote: eg: ``` dlib.d: extern(C) void dfun(){assert(0, "some_msg");} clib.cpp: extern "C" void dfun(); void fun(){ try{ dfun(); } catch(...){ // works but how do i get "some_msg" thrown from D? } } ``` I had the a

Re: Fast GC allocation of many small objects

2018-03-31 Thread Rémy Mouëza via Digitalmars-d-learn
On Saturday, 31 March 2018 at 09:10:13 UTC, Boris-Barboris wrote: On Friday, 30 March 2018 at 20:31:35 UTC, Per Nordlöw wrote: Is there a faster way of allocating many small class objects such as... maybe something like this: import std.conv: to; import std.stdio; class Node {} class

Re: Is there any way for non-blocking IO with phobos?

2018-11-13 Thread Rémy Mouëza via Digitalmars-d-learn
On Tuesday, 13 November 2018 at 13:52:57 UTC, Sobaya wrote: I want to connect to a server and communicate with ssh. So I tried to spawn the process of ssh using pipeProcess function, and read/write with its pipe's stdin and stdout. But I don't know how many lines are sent from the server for

Re: Why is creating of if Expressions not allowed?

2019-03-24 Thread Rémy Mouëza via Digitalmars-d-learn
On Sunday, 24 March 2019 at 16:18:49 UTC, sighoya wrote: Why auto GenIf()() { return mixin("if(true) { return true;} else {return false;}"); } public bool testFunction2() { GenIf!(); } gives me: onlineapp.d-mixin-3(3): Error: expression expected, not if onlineapp.d(8): Error:

Re: Reading Dicom files in Dlang

2019-06-03 Thread Rémy Mouëza via Digitalmars-d-learn
On Monday, 3 June 2019 at 14:19:40 UTC, Rnd wrote: On Friday, 31 May 2019 at 16:43:28 UTC, rnd wrote: On Friday, 31 May 2019 at 13:49:02 UTC, KnightMare wrote: struct Range { private __vector(ushort) _outer; private size_t _a, _b; this(vector(ushort) data, size_t a, size_t b) {

Re: Strange closure behaviour

2019-06-15 Thread Rémy Mouëza via Digitalmars-d-learn
On Saturday, 15 June 2019 at 01:21:46 UTC, Emmanuelle wrote: On Saturday, 15 June 2019 at 00:30:43 UTC, Adam D. Ruppe wrote: On Saturday, 15 June 2019 at 00:24:52 UTC, Emmanuelle wrote: Is it a compiler bug? Yup, a very longstanding bug. You can work around it by wrapping it all in another

Re: need article: How is working D-GC?

2019-06-11 Thread Rémy Mouëza via Digitalmars-d-learn
On Tuesday, 11 June 2019 at 18:20:59 UTC, KnightMare wrote: please write some explanation about subj. - what exactly it scans? - why it scan data-segment? https://issues.dlang.org/show_bug.cgi?id=15723 https://issues.dlang.org/show_bug.cgi?id=19947 precise GC doesn't help with issues. - maybe

Re: question about call cpp class constructer without new , and define cpp delegate

2019-06-27 Thread Rémy Mouëza via Digitalmars-d-learn
On Thursday, 27 June 2019 at 05:57:49 UTC, evilrat wrote: On Thursday, 27 June 2019 at 05:37:08 UTC, ChangLoong wrote: If I want call cpp class constructer without new method, is there a way to do that ? If what you really want is to actually allocate using C++ new operator from D, then that

Re: How to get name of my application (project)

2019-08-03 Thread Rémy Mouëza via Digitalmars-d-learn
On Saturday, 3 August 2019 at 09:26:03 UTC, Andrey wrote: Hello, how to get name of my application (project) that we write in dub.json? Is there any compile-time constant like __MODULE__? If I understand the question correctly, you are looking for std.file.thisExePath: -

Re: Pro programmer

2019-08-26 Thread Rémy Mouëza via Digitalmars-d-learn
On Monday, 26 August 2019 at 16:41:05 UTC, GreatSam4sure wrote: Thanks, is there tutorial on the translation of Java to D. Which tools is used? Pls guide me, I am really interested in translating JavaFX to D From what I can recall and find on the Internet, the tool used was named "tioport".

Re: Learning delegates

2019-09-08 Thread Rémy Mouëza via Digitalmars-d-learn
On Sunday, 8 September 2019 at 10:04:57 UTC, Joel wrote: I'm trying to understand delegates. Is there any good ways I can get a better understanding of them? I am no compiler implementer, so what is below may contain a lot of inaccuracies and conceptual shortcuts, but here is my view of

Re: Strange closure behaviour

2019-06-16 Thread Rémy Mouëza via Digitalmars-d-learn
On Sunday, 16 June 2019 at 01:36:38 UTC, Timon Gehr wrote: It's a bug. It's memory corruption. Different objects with overlapping lifetimes use the same memory location. Okay. Seen that way, it is clear to me why it's a bug. ... No, it's not the same. Python has no sensible notion of

Re: How to use ResizerWidget in Dlangui app..?

2020-01-01 Thread Rémy Mouëza via Digitalmars-d-learn
On Monday, 30 December 2019 at 23:32:37 UTC, ShadoLight wrote: Hi, I suspect I'm missing something obvious, but ResizerWidget is not working for me on Windows - it shows the 'dragging'-cursor when hovering the mouse on the ResizerWidget, but dragging with the left mouse button does nothing.