comp.lang.ada
 help / color / mirror / Atom feed
From: Volkert.Barr@freenet.de (Volkert)
Subject: Problems with the GNAT/C++ Interface.
Date: 1 Nov 2001 19:13:37 -0800
Date: 2001-11-02T03:13:37+00:00	[thread overview]
Message-ID: <b84db440.0111011913.7a6dd632@posting.google.com> (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



             reply	other threads:[~2001-11-02  3:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-02  3:13 Volkert [this message]
2001-11-03  9:53 ` Problems with the GNAT/C++ Interface Volkert Barr
2001-11-03 20:39   ` Jerry van Dijk
2001-11-05 15:24     ` Volkert Barr
replies disabled

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