🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.eiffel
Article #1123

Re: Calling C++ from C/Eiffel

#1123
From: vlad
Date: Sun, 24 Dec 1995 22:50
44 lines
2027 bytes
Paul Des Rivieres <pdesrivi@cse.dnd.ca> wrote:

>During the summer I contacted ISE support staff about how to call
>C++ from Eiffel.  They responsed that it was impossible because
>there was no way to call the C++ constructor.  Since I have a C++
>class interface to a mission critical C++ application one of my
>co-workers researched and found a solution.  Add the following
>routines to the C++ class:

>ClassName * ClassName::init_object (void)
>{
>   ClassName *cp;

>   if (!(cp = (ClassName *) malloc(sizeof(ClassName))))
>      return NULL;
>   *cp = ClassName();
>   return cp;
>}

>void ClassName::free_object (ClassName *cp)
>{
>   free(cp);
>}

>Then compile the C++ class keeping the interm C file (use +i for
>the CenterLine compiler).  Make note of the names of the C routines
>corresponding to the C++ routines.  In C/Eiffel call the C routine
>corresponding to ClassName::init_object then for the original C++
>routines call the corresponding C routines with ClassName *cp as the
>first parameter.
>Note: In Eiffel it is possible to have ClassName::free_object called
>with the object is garbage collected; inherit from MEMORY add redefine
>dispose to call ClassName::free_object (note: use C version's name).
> 
>---------------------------------------------------------------
> Paul Des Rivieres   Senior Computer Analyst/Programmer
> Communications Security Establishment, Govt of Canada, Ottawa
> pdesrivi@cse.dnd.ca  Voice: (613)991-8796  Fax: (613)991-8811

I use simmilar approach, when I want to access C++ library from
Smalltalk.


Vlastimil Adamovsky
Technical Details
Message-ID: <4bkl1r$dti@news2.ios.com>
Path: arc1-ca.pugleaf.net!news2.ios.com!usenet
References: <30D85476.2D63E6AE@cse.dnd.ca>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news2.ios.com!usenet
From: vlad@gramercy.ios.com (vlad)
Newsgroups: comp.lang.eiffel,comp.lang.c,comp.lang.c++
Subject: Re: Calling C++ from C/Eiffel
Date: Sun, 24 Dec 1995 22:50:07 GMT
Organization: Internet Online Services
Message-ID: <4bkl1r$dti@news2.ios.com>
References: <30D85476.2D63E6AE@cse.dnd.ca>
NNTP-Posting-Host: ppp-56.ts-8.hck.idt.net
X-Newsreader: Forte Free Agent 1.0.82