Re: Passing myself, a struct, as a C callback context

2015-03-30 Thread Paul O'Neil via Digitalmars-d-learn
On 03/30/2015 11:32 AM, Steven Schveighoffer wrote: On 3/30/15 5:12 AM, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net wrote: `this` is already a reference. You're taking the address of that reference. A simple cast should work: `cast(void*) this`. To build on this further, this for a

Passing myself, a struct, as a C callback context

2015-03-29 Thread Paul O'Neil via Digitalmars-d-learn
I'm registering a callback with some C code. The simplified story is here, but the actual code is on GitHub [1] at the end if you care. The call looks something like this. void register(void(*fp)(void*), void* context); I have a class that holds state for the callback and registers itself:

Re: Passing myself, a struct, as a C callback context

2015-03-29 Thread Paul O'Neil via Digitalmars-d-learn
On 03/29/2015 10:57 PM, weaselcat wrote: On Monday, 30 March 2015 at 02:53:36 UTC, Paul O'Neil wrote: As of dmd 2.067, doing this is deprecated. where is this documented? I don't see it in the release notes. I don't see it in the release notes either, but it's happening. Maybe it's an

Re: Nested C++ namespace library linking

2015-01-20 Thread Paul O'Neil via Digitalmars-d-learn
On Tuesday, 20 January 2015 at 21:10:59 UTC, Guillaume Chatelet wrote: Consider the following foo.cpp namespace A { namespace B { struct Type {}; int foo(Type unused){ return 42; } } } Compile it : g++ foo.cpp -c -o foo.o Then the following main.d extern(C++, A.B) { struct Type {}

Re: Binding non-trivial C++ structs

2014-12-17 Thread Paul O'Neil via Digitalmars-d-learn
On 12/17/2014 03:01 AM, Kagamin wrote: previous thread: http://forum.dlang.org/post/mailman.1464.1415039051.9932.digitalmar...@puremagic.com I read that thread. I don't understand if / how it answers this question. -- Paul O'Neil Github / IRC: todayman

Binding non-trivial C++ structs

2014-12-16 Thread Paul O'Neil via Digitalmars-d-learn
To make my C++ binding life easier, I wrote a small string structure [1] in C++ to use instead of std::string and produced the D declarations for some of it [2]. (It's not that complicated, I promise.) The important properties of this struct are that it has a non-trivial copy constructor and a

Re: Multiple declarations in a C++ namespace

2014-10-31 Thread Paul O'Neil via Digitalmars-d-learn
On 10/31/2014 12:55 AM, Meta wrote: On Friday, 31 October 2014 at 02:01:00 UTC, Paul O'Neil wrote: I'm trying to bind to some C++ code, but when I compile the D side, there are errors. Here's my reduced test case: // C++ namespace ns { void func1(); void func2(); } // D module

Multiple declarations in a C++ namespace

2014-10-30 Thread Paul O'Neil via Digitalmars-d-learn
I'm trying to bind to some C++ code, but when I compile the D side, there are errors. Here's my reduced test case: // C++ namespace ns { void func1(); void func2(); } // D module cpp; extern(C++, ns) void func1(); extern(C++, ns) void func2() dmd says:cpp_test.d(4): Error: namespace