From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id IAA11486; Wed, 21 Nov 2001 08:15:09 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id IAA04124 for ; Wed, 21 Nov 2001 08:15:08 +0100 (MET) Received: from gnu.in-berlin.de (gnu.in-berlin.de [192.109.42.4]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id fAL7F8T02365 for ; Wed, 21 Nov 2001 08:15:08 +0100 (MET) Received: from hirsch.in-berlin.de (root@hirsch.colt.in-berlin.de [213.61.118.6]) by gnu.in-berlin.de (8.10.1/8.10.1) with ESMTP id fAL7F2h09418 for ; Wed, 21 Nov 2001 08:15:02 +0100 (CET) (envelope-from cle@qiao.in-berlin.de) X-Envelope-From: cle@qiao.in-berlin.de X-Envelope-To: Received: from hirsch.in-berlin.de (uucp@localhost [127.0.0.1]) by hirsch.in-berlin.de (8.12.1/8.12.1/Debian -2) with ESMTP id fAL7F2Z6022537 for ; Wed, 21 Nov 2001 08:15:02 +0100 Received: (from uucp@localhost) by hirsch.in-berlin.de (8.12.1/8.12.1/Debian -2) with UUCP id fAL7F1B6022525 for caml-list@inria.fr; Wed, 21 Nov 2001 08:15:01 +0100 Received: (qmail 72679 invoked by uid 500); 21 Nov 2001 07:12:01 -0000 Date: Wed, 21 Nov 2001 08:12:01 +0100 From: Clemens Hintze To: Christophe TROESTLER Cc: "O'Caml Mailing List" Subject: Re: [Caml-list] Link with C++ code Message-ID: <20011121081201.A52894@qiao.in-berlin.de> References: <20011120.234149.54715310.debian00@tiscalinet.be> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20011120.234149.54715310.debian00@tiscalinet.be> User-Agent: Mutt/1.3.19i Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Tue, Nov 20, 2001 at 11:41:49PM +0100, Christophe TROESTLER wrote: > Hi all, Hi you, > I am trying to use some C++ code from OCaml. I am completely > inexperienced at this (and not knowing well C++ to make matters worse) > but in view of http://caml.inria.fr/Hump/msg778-782 that didn't seem > so difficult. I will likely have more questions later but I am > already stuck at the beginning. Indeed, the C++ code includes the > file "stl_alloc.h" which contains (gnu version, line 451) does this mean, *you* are including "stl_alloc.h" directly? This you should not do. You should not include any "stl_XXX.h" file. If you did not please forgive me. What you can do depends a bit on the version of the compiler you use right now. The closest-to-standard G++ should be the 3.x chain of GCC. Here all symbols of the STL are located in namespace 'std'. If your code do *not* using namespace std; you should not have problems then. Only, your code has to write std::whatever in front of every STL datatype you use. Other versions of GCC are not that close to the standard. They will simply obey and ignore the 'std' identifier the same time :-( > What can I do ? You could try to wrap the OCaml stuff into a namespace, propably. Like this: namespace ocaml { extern "C" { # include } } int main(int argc, char* argv[]) { : m = ocaml::alloc(...); : } HTH, Clemens. PS: Perhaps the OCaml headers could take sorrow on their own to wrap appropiate if included by an C++ compiler? Like this: #ifdef __cplusplus namespace OCaml { /* (1) */ extern "C" { #endif /* Normal header file contents goes here */ #ifdef __cplusplus } /* end of extern "C" */ } /* end of namespace OCaml */ /* (1) */ #endif Perhaps a bit more adaption would necessary if using lines (1)? ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr