Re: Wrapping C++ with C
From: Basile Starynkevitch [news] (basile-news_at_starynkevitch.net)
Date: 09/12/04
- Next message: Paul Pluzhnikov: "Re: malloc doesn't return"
- Previous message: Roger Leigh: "Wrapping C++ with C"
- In reply to: Roger Leigh: "Wrapping C++ with C"
- Next in thread: Paul Pluzhnikov: "Re: Wrapping C++ with C"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 12 Sep 2004 11:34:58 +0000 (UTC)
On 2004-09-12, Roger Leigh <${roger}@invalid.whinlatter.uklinux.net.invalid> wrote:
> For several reasons, I'd like to make use of C++ features such as
> templated functions and STL lists and maps in a C shared library.
> However, from the outside I'd like it to appear as a regular C library
> with a C API and not requiring a C++ compiler for linking. Is this
> possible? [....]
> I believe all I need to do is write the code as C++ code with the C
> wrapper functions declared as extern "C". Is this correct?
If your library needs to run code (e.g. called by constructors of
static data) before main, it probably need some special (constructor)
ELF section, and I believe this might be C++ specific (and maybe
requires a C++ link).
You should check that no constructors are called by your
library. Essentially, if it has no global data, it should help.
But I never worked on such stuff, so I probably forgot other issues.
-- Basile STARYNKEVITCH http://starynkevitch.net/Basile/ email: basile<at>starynkevitch<dot>net aliases: basile<at>tunes<dot>org = bstarynk<at>nerim<dot>net 8, rue de la Faïencerie, 92340 Bourg La Reine, France
- Next message: Paul Pluzhnikov: "Re: malloc doesn't return"
- Previous message: Roger Leigh: "Wrapping C++ with C"
- In reply to: Roger Leigh: "Wrapping C++ with C"
- Next in thread: Paul Pluzhnikov: "Re: Wrapping C++ with C"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|