From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,a60bbbe59db2715 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Newsgroups: comp.lang.ada Subject: Re: Interfacing C++ classes, but what about the destructor? References: <3rmsq8Fk1nvkU1@individual.net> From: Brian May Date: Thu, 20 Oct 2005 08:58:00 +1000 Message-ID: User-Agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:tjjjRWbQY+pZ8gKgzzcdF9zSByo= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Host: snoopy.microcomaustralia.com.au X-Trace: news.melbourne.pipenetworks.com 1129762680 202.173.153.89 (20 Oct 2005 08:58:00 +1000) X-Complaints-To: abuse@pipenetworks.com X-Abuse-Info: Please forward all headers to enable your complaint to be properly processed. Path: g2news1.google.com!news2.google.com!newsfeed.media.kyoto-u.ac.jp!news1.optus.net.au!optus!snewsf0.syd.ops.aspac.uu.net!news.netspace.net.au!news.melbourne.pipenetworks.com!not-for-mail Xref: g2news1.google.com comp.lang.ada:5810 Date: 2005-10-20T08:58:00+10:00 List-Id: >>>>> "Andreas" == Andreas Almroth 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