Re: Accessing C++ from C

From: Evan Carew (tempcarew_at_pobox.com)
Date: 01/08/04


Date: Thu, 08 Jan 2004 16:32:33 -0500

Rolf Magnus wrote:
> Evan Carew wrote:
>
>
[snip]
>
>
> Actually, there are C++ wrappers for the GNOME libs (e.g. gtkmm) and
> some gnome programs are actually written in C++. There are also quite
> some Un*x libs that are written in C++ and used from C programs, or
> even plugin systems where the plugins and the main program are not
> written in the same language, so glueing C code and C++ code together
> isn't actually that uncommon.
I've seen the fine job the gtkmm folks did with the C++ wrapper, I've
also been stepping through the underlying gtk code as of late & that is
exactly why I am here talking about this technique. In other words, it
sure would be nice to be able to refactor this code in an OO environment.

As for gluing C to C++, yes, it is done, but what I have been seeing up
to now has involved use of knowledge in how C++ mangles its names & then
tying that into the C environment. Not what I would call generic
programming (or version stable for that matter).

I've also been informed recently that there are some projects as you
describe which utilize this technique, however, for some reason its use
hasn't been documented in any texts, or manuals I have seen. Even the
article in C/C++ Users Journal I saw didn't discuss the issues related
to getting your compiler to actually link all the code together. Perhaps
this subject could stand some dissemination.
>
>
>>With this technique, someone could refactor their libraries in C++ and
>>provide a C wrapper for those still using legacy techniques, while
>>newer developers could go on to use C++.
>
>
> Some developers want to use C rather than C++.
Yep, especially if they are embedded programmers like myself. There is a
place for C++ and typically, embedded programming isn't it. On the other
hand, GUI programming is perfect for C++ & I can't understand why some
projects persist in having their core development done in C (like
GNOME). KDE for example is done (mostly) in standard C++ & is rather
pleasant to program in. Gnome on the other hand is done entirely in C as
are most of its core components & working with those is ... well... lets
just say that it could be better. While the C++ wrapper libraries for
GNOME are fine, it is a little like kissing through saran wrap. If you
need to change anything, you still need to drop into C.



Relevant Pages

  • Re: I ought to be a writer (I think)...
    ... The technique is surprisingly difficult to teach, I found, because it ... But it's actually more like demolishing a castle one brick at a time. ... would *not* have worked in some of the early programming languages ... To demolish the remains of a castle: ...
    (rec.arts.sf.composition)
  • Re: I ought to be a writer (I think)...
    ... The technique is surprisingly difficult to teach, I found, because it ... But it's actually more like demolishing a castle one brick at a time. ... would *not* have worked in some of the early programming languages ... To demolish the remains of a castle: ...
    (rec.arts.sf.composition)
  • Re: Future of C#
    ... widespread and F# can only broaden its use. ... obscure technique because only educated people know and use it. ... programming, database programming and windows application programming but ... Scientific computing is often performed on non-Windows boxes. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: c.u.s. FAQ, take two
    ... >> This technique works even in a pipe or when otherwise reading stdin. ... just moderate programming experience and some familiarity ... with basic awk syntax and shell quoting rules should be enough. ... How's that as a candidate for FAQ? ...
    (comp.unix.shell)
  • Re: kde vs gnome
    ... Nicholas Wieland wrote: ... it doesn't matter what programming language or license ... > projects for Gnome and 381 for Kde: not bad if you think that GNOME is a ...
    (comp.unix.bsd.freebsd.misc)