comp.lang.ada
 help / color / mirror / Atom feed
From: Brian May <bam@snoopy.apana.org.au>
Subject: Re: Interfacing C++ classes, but what about the destructor?
Date: Thu, 20 Oct 2005 08:58:00 +1000
Date: 2005-10-20T08:58:00+10:00	[thread overview]
Message-ID: <sa4ll0pjerr.fsf@snoopy.microcomaustralia.com.au> (raw)
In-Reply-To: 3rmsq8Fk1nvkU1@individual.net

>>>>> "Andreas" == Andreas Almroth <andreas_no_spam@almroth.com> writes:

    Andreas> Hi all, I have been searching google, and read the Gnat
    Andreas> RM&UG, and I have some working code interfacing C++
    Andreas> classes. No problem really so far, although it feels as
    Andreas> if I'm wading in unchartered waters... Documentation
    Andreas> seems to be sparse, although the documentation that is
    Andreas> there pretty much shows you how to do it...

I think you have already done way more then most of us - I seem to
remember the recommended approach is usually to write a C layer
between the Ada layer and C++ layer.

    Andreas> My question is though on the topic of C++ class
    Andreas> destructors. When I search, I find references to
    Andreas> CPP_Destructor pragma in some documentation, but when I
    Andreas> compile the code, I get a warning stating that the pragma
    Andreas> is unknown. I have tried GNAT 3.15p, gcc 3.4.2 and gcc
    Andreas> 4.0.1, all the same.

I can't see any documentation on the CPP_Destructor call here (version
3.4 info pages).

    Andreas> As the pragma doesn't seem to exist, contrary to older
    Andreas> documentation, I assume it it has been removed due to it
    Andreas> doesn't work, or was deemed unneccesary.

    Andreas> Regardless of reasons, I 1) wonder the history behind
    Andreas> this, 2) how to call the destructor of the C++ class from
    Andreas> Ada side, or why I shouldn't.

Sorry, I suspect you may not get much help here :-(.

The example in my copy of the UG "2.11.3 A Simple Example" appears to
use C bindings, not C++ bindings, even though the language is C++. A
good example that uses C++ bindings would be appreciated...

However, I would speculate that a virtual destructor (remember
destructor don't need to be virtual, but it seems like a good idea) is
treated like any other virtual function.

This might imply GNAT will not call the destructor automatically for
you.
-- 
Brian May <bam@snoopy.apana.org.au>



  reply	other threads:[~2005-10-19 22:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-19 12:34 Interfacing C++ classes, but what about the destructor? Andreas Almroth
2005-10-19 22:58 ` Brian May [this message]
2005-10-19 23:40   ` Andreas Almroth
replies disabled

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