svn commit: samba r18030 -in branches/SAMBA_3_0/source/tdb/common: .

Dave Daugherty dave.daugherty at centrify.com
Fri Sep 8 04:38:25 GMT 2006


We also are using TDB with a thin C helper/wrapper (that I sent to
Jeremy in case the Samba team wanted it) that we in turn call from C++
code.  It works very well. Thanks very much for LGPL'ing this code.

In general we find calling C code from C++ works fine. Sometimes with we
have to wrap the include headers in an extern "C" {...}, to prevent name
mangling, etc. but that's easy.

Going the other way - C code calling C++ code via a C wrapper - you have
to be very careful to catch all exceptions because the C code does not
know what to do with them.  In general this means a catch (...) just
before exiting the C wrapper - just to be sure.

We have the luxury of building on all of our platforms with GNU
compilers. Sometimes we have problems getting them to work properly on
foobar version of funix, but it's probably a lot easier than the Samba
team has it - making sure Samba builds using everyone's compilers and
linkers.

Dave Daugherty
Centrify Corp.

On Mon, 2006-09-04 at 22:53 +1000, tridge at samba.org wrote:

>> Is it really practical to make our libraries usable in real C++
>> programs, without adding a lot of C++ specific code?
>> 
>> Is a fairly complex C library like tdb really usable in real C++
>> programs?  I am certainly no C++ expert, but I thought there was a
bit
>> more to it than just getting it to compile.

Tim Potter wrote: September 07, 2006 6:01 PM

> I use both tdb and ldb (a pre-libreplace version) in production code
at
> work.  For tdb a C++ wrapper is quite simple as I'm just putting
> tdb_open() in the constructor, tdb_close() in the destructor, and
> converting TDB_DATA structures to C++ std::string objects.

> For ldb a wrapper is a bit trickier, as the parent/child memory
hierachy
> doesn't lend itself to making each C struct an object so it was easier
> just to use the C ldb API within a higher level C++ class.


Tim.


More information about the samba-technical mailing list