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,1be082612b8c5f2e X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!API-DIGITAL.COM-a2kHrUvQQWlmc!not-for-mail Date: Sat, 05 Jun 2010 13:47:26 -0500 From: "Marc A. Criley" User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9) Gecko/20100423 Thunderbird/3.0.4 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Dynamically tagged expression not allowed. Why? References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <6a0a$4c0a9bce$433a4eca$18947@API-DIGITAL.COM> X-Complaints-To: abuse@usenetserver.com Organization: UseNetServer.com X-Trace: 06a0a4c0a9bcee69feb6f18947 Xref: g2news2.google.com comp.lang.ada:12286 Date: 2010-06-05T13:47:26-05:00 List-Id: On 06/01/2010 06:36 PM, Randy Brukardt wrote: > "Marc A. Criley" wrote in message > news:c2ead$4c0150a0$4ca4a823$11809@API-DIGITAL.COM... > ... >> Stripping out a test case, I see that it has nothing to with the C++ >> binding per se, but it's an Ada issue that's flummoxing me. Here's the >> test code: >> >> procedure Dyty_Test is >> >> type Class_Type is tagged limited record >> null; >> end record; >> >> function New_Class_Instance return Class_Type'Class; >> >> Conn : Class_Type := New_Class_Instance; > > This is illegal because the function returns a class-wide object and you are > assigning it into an object of a specific type. You have to explicitly use a > type conversion here: > > Conn : Class_Type := Class_Type (New_Class_Instance); > > to specify that you want to truncate the returned object, or make the object > classwide: > > Conn : Class_Type'Class := New_Class_Instance; > > But notice that while both of these are legal, they'll both raise > Program_Error because an access-before-elaboration error (the body of > New_Class_Instance hasn't been elaborated at the point of this call). Actually, stripping out the C++ interface pragmas was probably a bad idea on my part. (Though the thread *was* educational :-) I thought that to create an instance of the C++ class I had to invoke the New_Class_Instance function myself, from which arose this issue. Turns out I don't. GNAT's handling of the C++ pragmas does it all for me automagically. The documentation on creation an Ada binding to C++ is somewhat...terse when it comes to describing the mechanics of what is going on "under the hood", from whence came my misunderstanding. So this part is all better now, I can step in and verify that my constructors are being executed. I'm having other problems, but that's just the usual banging the head against the wall stuff. Marc A. Criley www.mckae.com