Wrapping C++ in C.

Kevin Atkinson kevinatk@home.com
Thu Feb 3 18:44:00 GMT 2000


On Thu, 3 Feb 2000, Phil Edwards wrote:

>  Kevin Atkinson <kevinatk@home.com> writes:
> > On Thu, 3 Feb 2000, Joe Buck wrote:
> >
> > > You can use gcc rather than g++ to link, provided that you add
> > > 	-lstdc++ -lm
> > > to the end of your link line.
> >
> > What is the C++ code is in a shared library?
>        ^^
> On the assumption that you meant to type "if" there, 

Yes.

> then you would treat
> the C++ library like any other library, e.g., object files and libraries
> that use symbol <FOO> should precede those that define symbol <FOO>,
> for maximum portability.
> 
> As far as g++'s code, the "stdc++" that Joe mentioned above /is/
> the library.

I mean a C program is using a C++ library with has functions in extern C
linkage.

How do global variables in libraries compiled by other C compiles get
initialized?

> > Also how do static variables in those libraries get initialized?
> >
> > > > 2) Is it possible to get a function pointer out of a C++ member
> > > > function?
> > > 
> > > These are general C++ language questions, not for this list.  A pointer
> > > to member function and a pointer to function are very different beasts.
> >
> > Yes I know that.  That was NOT my question.  I am looking for a gcc
> > specific answer.  As I understand it member functions are almost like
> > normal functions except that there is a hidden this parameter and for
> > virtual member functions there is also a lookup on the virtual table.
> 
> Nothing that you've said there is gcc-specific.  The same caveats apply
> no matter what compiler is being used, and the syntax will be the same
> no matter what compiler is being used; Joe's answer is still true.
> I recommend searching comp.lang.c++[.moderated] and comp.std.c++
> in DejaNews.

I am not interested in retrieving a member function pointer.  I am
interested in retrieving a C function pointer out of a member function.
Please see my original post.

---
Kevin Atkinson
kevinatk@home.com
http://metalab.unc.edu/kevina/



More information about the Gcc mailing list