comp.lang.ada
 help / color / mirror / Atom feed
* Problems with the GNAT/C++ Interface.
@ 2001-11-02  3:13 Volkert
  2001-11-03  9:53 ` Volkert Barr
  0 siblings, 1 reply; 4+ messages in thread
From: Volkert @ 2001-11-02  3:13 UTC (permalink / raw)


Hello c.l.a!

Problem: I want an Ada Binding to the following recursive C++ 
class declaration:

class Chainable {

public:
       
  Chainable *next, *prev;
  
  Chainable();
  void reset();

};

The following Ada package Chainable_Type seams for me an 
obvious corresponding Ada type declaration:

package Chainable_Type is

   type Chainable;
   type Chainable_Access is access all Chainable'Class;

   type Chainable is tagged limited
      record
         next        : Chainable_Access;
         prev        : Chainable_Access;
      end record;

    ...

end Chainable_Type;

So far so good. Now i say the GNAT Compiler that the tagged type 
Chainable has to be mapped to the corresponding C++ class:

package Chainable_Type is

   type Chainable;
   type Chainable_Access is access all Chainable'Class; -- (*)

   type Chainable is tagged limited
      record
         next        : Chainable_Access;
         prev        : Chainable_Access;

         Vptr : Interfaces.CPP.Vtable_Ptr; -- new
      end record;

   pragma CPP_Class (Entity => Chainable); -- new

   ...

end Chainable_Type;

compiling this package gnat says: 
  
  error : pragma "Cpp_Class" applicable to a record, tagged record or
  record extension.

Ok, the problem seems the incomplete type declararion 
in line (*). Do is miss something?

Volkert



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2001-11-05 15:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-02  3:13 Problems with the GNAT/C++ Interface Volkert
2001-11-03  9:53 ` Volkert Barr
2001-11-03 20:39   ` Jerry van Dijk
2001-11-05 15:24     ` Volkert Barr

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox