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: 2008-01-01 02:47:48


On Mon, 2007-12-31 at 20:01 -0700, Brian Barrett wrote:
> On Dec 31, 2007, at 7:26 PM, Adam C Powell IV wrote:
>
> > 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!
>
> Yeah, this is a complicated example, mostly because HDF5 should
> really be covering this problem for you. I think your only option at
> that point would be to use the #define to not include the C++ code.
>
> The problem is that the MPI standard *requires* mpi.h to include both
> the C and C++ interface declarations if you're using C++. There's no
> way for the preprocessor to determine whether there's a currently
> active extern "C" block, so there's really not much we can do. Best
> hope would be to get the HDF5 guys to properly protect their code
> from C++...

Okay. So in HDF5, since they call MPI from C, they're just using the C
interface, right? So should they define OMPI_SKIP_MPICXX just in case
they're #included by C++ and using OpenMPI, or is there a more MPI
implementation-agnostic way to do it?

Thanks again and happy new year!

-Adam

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