cpp header bindings

Bill Baxter wbaxter at gmail.com
Tue Jul 29 22:43:03 PDT 2008


Interop with C++ is a fairly new addition to the language, and only in
D2 I believe.  I don't think either bcd or htod know how to handle
C++. So they're not likely to work.

In your hand-wrapping of the C++ you do this:

"""
extern (C) {
class TheTest
{
public:
  this (int);
  void myfirst ( int myf );
  void mysecond ( int myff );
  ~this();
private:
  int p_Myf;
  int p_Myff;
  int p_Mytotal;
}}
"""

Which has little chance of working since classes don't have any
meaning in C.  It might work using extern(C++) with a D2 compiler.
I've not done much with D2, though (no Tango, no DWT), so I couldn't
say for sure.

--bb

On Wed, Jul 30, 2008 at 2:33 PM, RCJ <rmcjustino at gmail.com> wrote:
> Rui Justino Wrote:
>
> Well once more sorry for the very long post.
> Let me try to clarify the problem. I'm trying to create an interface from cpp to d with the following files.
>
> ./bcd/my4/thetest.d
> ./thetest.h
> ./thetest.cpp
> ./thetest.d
> ./header_tit.d
>
> cpp files are working, but when i try to create bindings to that header file i get to a point were i receive the same error using 2 different approaches. For the binding there are two files, one created by BCD and the other by h2d ("./thetest.d" and "./bcd/my4/thetest.d").
> With this 2 different approaches I receive the same exact error message, in 2 different versions of GDC.
>
> I would be grateful if some one could show me my error.
>> ----------------------------------------------------------------------------------------
>> #gdmd header_tit.d thetest.o -L-lstdc++
>> header_tit.o: In function `_Dmain':
>> header_tit.d:(.text+0x20): undefined reference to `_D7thetest7TheTest7__ClassZ'
>> header_tit.d:(.text+0x2f): undefined reference to `_D7thetest7TheTest5_ctorMUiZC7thetest7TheTest'
>> collect2: ld returned 1 exit status
>> ----------------------------------------------------------------------------------------
>


More information about the Digitalmars-d-learn mailing list