From: Elias Athanasopoulos <elathan@pcmag.gr>
To: linux-c-programming@vger.kernel.org
Subject: mixing C/C++
Date: Mon, 24 Nov 2003 13:10:50 +0200 [thread overview]
Message-ID: <20031124111050.GI1819@pcmag.gr> (raw)
Hello!
Consider:
class Bar {
public:
Bar();
~Bar();
void dump2(void);
};
class Foo : public Bar {
public:
Foo();
~Foo();
void dump(void);
};
extern "C"
Foo * wrap_foo_ctor()
{
return new Foo();
}
extern "C"
void wrap_foo_dump(Foo *f)
{
f->dump();
}
extern "C"
void wrap_bar_dump2(Bar *b)
{
b->dump2();
}
Now, I have a C program:
int main(void)
{
struct Foo *f;
f = wrap_foo_ctor();
wrap_foo_dump(f);
wrap_bar_dump2(f);
}
which is working as -at least- I expect. Bar::dump2() is
called since Foo inherits from Bar.
However is it correct? I have a larger C++ project, which I'm
creating wrappers for in C, and I get a segfault in a similar
case (i.e. when I call a method *deep* inside the inheritence tree of a
class).
Regards,
--
Elias Athanasopoulos
http://www.pcmag.gr - Libecom S.A.
next reply other threads:[~2003-11-24 11:10 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-24 11:10 Elias Athanasopoulos [this message]
2003-11-24 12:18 ` mixing C/C++ Steven Shaw
2003-11-24 17:55 ` Elias Athanasopoulos
2003-11-25 2:21 ` Steven Shaw
2003-11-25 10:49 ` elathan
2003-11-25 11:42 ` Glynn Clements
2003-11-25 13:12 ` elathan
2003-11-26 2:09 ` Glynn Clements
2003-12-02 18:22 ` Elias Athanasopoulos
2003-11-25 16:32 ` Steven Shaw
2003-11-24 18:44 ` Dari'o Mariani
-- strict thread matches above, loose matches on Subject: below --
2003-11-08 9:30 Elias Athanasopoulos
2003-11-08 13:36 ` James Stevenson
2003-11-10 15:00 ` Matthew Studley
2003-11-10 17:37 ` Elias Athanasopoulos
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20031124111050.GI1819@pcmag.gr \
--to=elathan@pcmag.gr \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).