Below is a solution to get it to work as a C binding.
- Your structure should not be enclosed in the `extern (C)`
block; leave it as regular D code.
- cppcall should be declared `extern (C)` in D and `extern "C"`
in C++;
- depending on your platform, you need to link to the C++
standard lib ;
This looks like a case study for aspect oriented programming:
several separated concerns that start to intertwine within your
code; if left unchecked this could result in some messy code.
In Python, I used reflection and "magic" things and have already
used the spring AOP in Java that is done
For the two first ones, I would use an alias:
alias GetCurrentThreadId pthread_self;
alias void * pthread_handler_t;
The third one is a function pointer alias:
alias void * function (void *) pthread_handler;
For the last one, I am not sure, being rusty with the C preprocessor
rule
I had played with that idea and searched the forums once.
I came up with the following proof-of-concept code.
in C (c_dg.c) {
#include
/// This is how a delegate is implemented (currently).
typedef struct Dg {
/// The context (class instance or frame or null).
void
My strategy here would be to:
A. run the program in a debugger, say GDB, to get a exhaustive
stacktrace for hints about where to look at.
B. have a quick look at the library directly (the "Use the Source Luke"
strategy).
Since I was curious about your problem (you had everything correct -
th
It works fine when using dup to the value returned by nativeToBigEndian:
public void opAssign(uint value)
{
this._octets = value.nativeToBigEndian().dup;
assert(this._octets == cast (ubyte[]) [1, 2, 3, 4]);
}
On 12/13/2013 06:35 PM, John Colvin wrote:
On Friday, 13
As Chris wrote, using double quotes to use strings instead of char
solves the typing issse.
I'd also suggest the following alternative, if you're going to discard a
lot of last elements in your code:
import std.stdio;
import std.algorithm;
import std.array;
import std.range;
The popBack function returns the element you are removing from the
array, not the array itself, thus "breaking" the chaining of function.
On 01/01/2014 08:36 AM, Dfr wrote:
This is interesting, why i can't just do it simpler way ?
"this.is.a.string"
.splitter (".")
You can use `std.conv.to` to convert the dchar[] back to a string,
adding `.to!string` at the end of the dchar[] array you want to convert.
Also not that there exists two similar functions to the lazy evaluated
splitter() and joiner() in std.array: the eagerly evaluated split() and
join(); bei
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 StrNod
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
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: templ
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 sim
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) {
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 add
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 l
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
variab
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
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:
- http://dpldocs.info/
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".
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
dele
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.
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 h
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,
ATTR_
s not an enum, e.g.:
const int FOO?
>
> On 08/14/2014 01:23 PM, Rémy Mouëza wrote:
>> Using __traits (identifier, ...) and a template alias seems to work
for me:
>>
>> import std.stdio;
>>
>> /// Two kinds of enums:
>>
>> /// A named enum.
>&g
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 --
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:
[Environment
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/ -L-Ldruntime-ldc .
On 08/31/2014 05:52 PM, seany wrote:
I am linking against tango
ldc -I/path/to/tango -L-L
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/ -L-Ldruntime-ldc .
there is
a_end(char*)
If you get a similar result, your next step will be to try compiling
your program with phobos.
On 08/31/2014 11:09 PM, Rémy Mouëza wrote:
Have you tried something like this:
find /lib /usr/lib* /usr/local/lib* -name \*.a | grep -i druntime
or a simple:
locate druntime
?
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
missing
31 matches
Mail list logo