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-10-02 08:36:31 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!sn-xit-03!sn-xit-06!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: "Matthew Heaney" Newsgroups: comp.lang.ada Subject: Re: Export to a Namespace? Date: Wed, 2 Oct 2002 11:35:01 -0400 Organization: Posted via Supernews, http://www.supernews.com Message-ID: References: <3D948F1F.9A87CE48@boeing.com> X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Complaints-To: abuse@supernews.com Xref: archiver1.google.com comp.lang.ada:29466 Date: 2002-10-02T11:35:01-04:00 List-Id: "Jeremy T. Smith" wrote in message news:3D948F1F.9A87CE48@boeing.com... > > 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; > } The problem is you don't know how the compiler mangles names. What I would do is use extern but with C linkage, e.g. extern "C" { extern int My_Wrapper_First_Val; extern int My_Wrapper_Next_Val; } or something like that. I'm not sure external linkage and C++ namespaces are really compatible. If you really want to keep the namespace, you could try something like: namespace My_Wrapper { int First_Val(); int Next_Val(); } inline int My_Wrapper::First_Val() { return My_Wrapper_First_Val; } inline int My_Wrapper::Next_Val() { return My_Wrapper_Next_Val; } or something like that.