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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1b85793c9263ca04 X-Google-Attributes: gid103376,public From: James Huckaby Subject: Re: C++ to Ada Link Problems Date: 1998/02/27 Message-ID: <34F7266D.203BF762@mps.lmtas.lmco.com>#1/1 X-Deja-AN: 329259453 Content-Transfer-Encoding: 7bit References: <9802271359.AA07254@nile.gnat.com> <34F6CC30.D8B74ACB@mps.lmtas.lmco.com> <34F71D58.2781@hso.link.com> To: "Stanley R. Allen" Content-Type: text/plain; charset=us-ascii Organization: Lockheed Martin - Tactical Aircraft Systems Mime-Version: 1.0 Reply-To: James.B.Huckaby@LMCo.com Newsgroups: comp.lang.ada Date: 1998-02-27T00:00:00+00:00 List-Id: Stanley R. Allen wrote: > But by the wording of your question, I suppose that you > have alreasy worked out those issues and are trying now > to build an executable. The main issue is C++ constructor/ > deconstructor ("Xtor") operations for statically-declared > object instances: how do they get called? In Ada, global > variable initialization is defined in the language as > part of the elaboration process. In C++, it is the > job of external tools. A common way of creating the > contructor/destructor caller is to "munch" the object > code produced by the C++ compiler (using a munching > tool), which will produce a C file that calls the > Xtors. Compiling this C file and linking the new > object module with the C++ code will ensure that the > C++ static objects are constructed properly. To link > with Ada, ensure that the object file created from > the C program is included as one of the inputs to the > linker building the Ada main. (Since you are talking > about Ada 83, I assume that the main program is in Ada.) > My understanding is that munching is the approach > used by the GNU C++ implementation. > > Other C++ compilers don't require a separate munching > phase, but expect that the linker will include calls > to the proper contructor/destructors. If the Ada > binding program (I think that would be a.ld for SunAda) > is used to create the Unix "ld" command, then the > stuff C++ needs will not be included. I'm not sure how > it works on the Sun; on the SGI with Delta C++ you can > specify that the C++ compiler itself ("CC") be used as > the linker. This will include the necessary code to > call the Xtor operations for static C++ objects. I think I might be able to redirect the a.ld command to use CC instead of ld (it will probably be trial and error for awhile). Do you have any examples of munchers or munching tools? I did a Yahoo! search and it was very fascinated about the wrong sort of munching and the painter Muench. (ue = u umlaut) ''``''``''``''``''``''``''``''``''``''``''``''``''``''``''``'' James Huckaby mailto:James.B.Huckaby@LMCo.com ''``''``''``''``''``''``''``''``''``''``''``''``''``''``''``'' ``''``''``''``''``''``''``''``''``''``''``''``''``''``''``''``