Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

Subject: Re: [OMPI users] Can't compile C++ program with extern "C" { #include mpi.h }
From: Adam C Powell IV (hazelsct_at_[hidden])
Date: 2007-12-31 21:26:03


On Mon, 2007-12-31 at 19:17 -0700, Brian Barrett wrote:
> On Dec 31, 2007, at 7:12 PM, Adam C Powell IV wrote:
>
> > I'm trying to build the Salomé engineering simulation tool, and am
> > having trouble compiling with OpenMPI. The full text of the error
> > is at
> > http://lyre.mit.edu/~powell/salome-error . The crux of the problem
> > can
> > be reproduced by trying to compile a C++ file with:
> >
> > extern "C"
> > {
> > #include "mpi.h"
> > }
> >
> > At the end of mpi.h, the C++ headers get loaded while in extern C
> > mode,
> > and the result is a vast list of errors.
>
> Yes, it will. Similar to other external packages (like system
> headers), you absolutely should not include mpi.h from an extern "C"
> block. It will fail, as you've noted. The proper solution is to not
> be in an extern "C" block when including mpi.h.

Okay, fair enough for this test example.

But the Salomé case is more complicated:
extern "C"
{
#include <hdf5.h>
}
What to do here? The hdf5 prototypes must be in an extern "C" block,
but hdf5.h #includes a file which #includes mpi.h...

Thanks for the quick reply!

-Adam

-- 
GPG fingerprint: D54D 1AEE B11C CE9B A02B  C5DD 526F 01E8 564E E4B6
Engineering consulting with open source tools
http://www.opennovation.com/