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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1f9be55dffd75804 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-09-27 12:00:36 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: Export to a Namespace? Date: 27 Sep 2002 14:52:49 -0400 Organization: NASA Goddard Space Flight Center (skates.gsfc.nasa.gov) Message-ID: References: <3D948F1F.9A87CE48@boeing.com> NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 1033153395 16216 128.183.220.71 (27 Sep 2002 19:03:15 GMT) X-Complaints-To: usenet@news.gsfc.nasa.gov NNTP-Posting-Date: 27 Sep 2002 19:03:15 GMT User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: archiver1.google.com comp.lang.ada:29387 Date: 2002-09-27T19:03:15+00:00 List-Id: "Jeremy T. Smith" writes: > I'm supporting a large mass of legacy Ada and my boss wants to add new > functions using C++. There are about 2000 constants defined in the Ada > code that we'll need visible to C++. Not a problem, a quick Perl script > will add a pragma Export after each declaration. The values being > exported are resolved at compile time, otherwise I'd just duplicat the > declarations in C++. > > BUT, our system architect is a stickler about not polluting the global > namespace, so can I export from Ada to a C++ namespace? Perhaps > something like (though this won't compile on my Green Hills compiler): > > C++ Side: > namespace My_Wrapper { > extern int First_Val; > extern int Next_Val; > } > > Ada Side: > First_Val : constant integer := Some_Withed_In_Named_Number; > pragma Export(CPP, First_Val, "My_Wrapper::First_Val"); > Next_Val : constant integer := First_Val'Succ; > pragma Export(CPP, Next_Val, "My_Wrapper::Next_Val"); > > Any help would be much appreciated, even if it's just a "You can't do > that"! Find out how the C++ compiler mangles the C++ name to the link name; it may be something like My_Wrapper@Next_Val, but it's probably worse. Then use the Link_Name parameter of Export to specify that link name. As Pascal said, it would be better to fix your boss! -- -- Stephe