[petsc-dev] Compiling C code with C compiler

Dmitry Karpeev karpeev at mcs.anl.gov
Mon Apr 4 21:24:02 CDT 2011


struct _p_Mat {
  PETSCHEADER(struct _MatOps);
  PetscLayout            rmap,cmap;
  ...
}
typedef struct _p_Mat *Mat;
Mat A;
Now ((PetscObject)A)->comm is kosher, because of the way C lays out the
struct.
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).

Dmitry.

On Mon, Apr 4, 2011 at 9:18 PM, Sean Farley <sean at mcs.anl.gov> wrote:

> But why would I do that? The whole point of  invoking 'clang++' is to to
>> compile the
>>  code as 'C++' - not as 'C'
>
>
> Why not try to compile C code with a C compiler and C++ code with a C++
> compiler? (Perhaps I missed a previous discussion?) Dmitry brought up an
> interesting question of which I don't know the answer off the top of my
> head.
>
> Dmitry, is there a small code example that shows this?
>
> Sean
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20110404/3cc5d81b/attachment.html>


More information about the petsc-dev mailing list