Topic: c interface for c++ classes
Author: frank@cadlab.de (Frank Rupprecht)
Date: 24 Jan 92 09:50:53 GMT Raw View
Hey,
does anybody know a standard or some rules for desiging a c interface for c++
classes? I.e. naming constrains, sequence of parameters (in, inout, in),
posisiton of the additional parameter which represents the object of the
method, etc.
There are some hints in a documentation of sun for wrappers, but it is only a
first small step, I think.
Thanks
Frank Rupprecht
--
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Frank T. Rupprecht Tel. : (+49) (+) 5251-284144 +
+ Cadlab Fax. : (+49) (+) 5251-284140 +
+ Bahnhofstrasse 32 Email : frank@cadlab.de +
+ 4790 Paderborn frank@cadlab.uucp +
+ Germany ...!uunet!unido!cadlab!frank +
+ frank@uni-paderborn.de +
+ frank@pbinfo.uucp +
+ ...!uunet!unido!pbinfo!bb +
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Author: cimshop!davidm@uunet.UU.NET (David S. Masterson)
Date: 24 Jan 92 18:19:20 GMT Raw View
>>>>> On 24 Jan 92 09:50:53 GMT, frank@cadlab.de (Frank Rupprecht) said:
> does anybody know a standard or some rules for desiging a c interface for
> c++ classes? I.e. naming constrains, sequence of parameters (in, inout, in),
> posisiton of the additional parameter which represents the object of the
> method, etc.
The only safe approach I've seen is to develop C-style functions that call the
appropriate member functions on your objects:
class A { /*member info*/ };
extern "C" func(/*parmlist*/)
{
A a; /* either locally or globally declared */
a.memberfunc();
...
}
Your C using clients would call these "envelope" functions in order to work
with the pure C++ routines. I've yet to do this, though, so I'm not sure of
all the "gotchas". One well-known "gotcha", though, is initialization of
global objects that your "C++" library (I assume all the func()'s are in a
library) might be using. Presumably, your C users have written and compiled
most of their code (including the main routine) using C and a C compiler.
There is usually some sort of "magic" that C++ compilers perform to ensure
that the global information is set up before the main routine starts. You'll
have to determine how much of a problem this is for you.
--
====================================================================
David Masterson Consilium, Inc.
(415) 691-6311 640 Clyde Ct.
uunet!cimshop!davidm Mtn. View, CA 94043
====================================================================
"Boldly going where no one has gone before."