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 21:17:13

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


   Brian Barrett
   Open MPI developer