[petsc-dev] Compiling C code with C compiler

Jed Brown jed at 59A2.org
Tue Apr 5 01:36:36 CDT 2011


On Tue, Apr 5, 2011 at 04:24, Dmitry Karpeev <karpeev at mcs.anl.gov> wrote:

> I don't know whether C++ does the same (there is the issue of where it
> sticks the vtable, and I'm not sure what else).
> I imagine there will be no problem, since we've been compiling the PETSc C
> code with C++ compilers for a decade now,
> but I don't know whether the C++ standard guarantees that.  Jed is the only
> person I know that actually reads the standard
> (or maybe it's part of the ABI).
>

As far as the implementation, there is no vtable because we don't put C++
virtual methods in the struct. The standard does not say anything about the
existence of a vtable, but it does make the same sort of guarantees about
struct layout. I do not know if you can guarantee that a struct within an
extern "C" block is binary compatible with a struct outside an extern "C"
block that does not happen to contain a vtable.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20110405/d521d0fc/attachment.html>


More information about the petsc-dev mailing list