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: Brian Barrett (brbarret_at_[hidden])
Date: 2007-12-31 22:01:26

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++...


   Brian Barrett
   Open MPI developer