I've just run into this chunk of code.

/* MPICH2 will fail if SEEK_* macros are defined
 * because they are also C++ enums. Undefine them
 * when including mpi.h and then redefine them
 * for sanity.
 */
#  ifdef SEEK_SET
#    define MB_SEEK_SET SEEK_SET
#    define MB_SEEK_CUR SEEK_CUR
#    define MB_SEEK_END SEEK_END
#    undef SEEK_SET
#    undef SEEK_CUR
#    undef SEEK_END
#  endif
#include "mpi.h"
#  ifdef MB_SEEK_SET
#    define SEEK_SET MB_SEEK_SET
#    define SEEK_CUR MB_SEEK_CUR
#    define SEEK_END MB_SEEK_END
#    undef MB_SEEK_SET
#    undef MB_SEEK_CUR
#    undef MB_SEEK_END
#  endif


MPICH2 (1.1.0a1) gives these errors if SEEK_* are present:

/opt/mpich2/include/mpicxx.h:26:2: error: #error "SEEK_SET is #defined but must 
not be for the C++ binding of MPI"
/opt/mpich2/include/mpicxx.h:30:2: error: #error "SEEK_CUR is #defined but must 
not be for the C++ binding of MPI"
/opt/mpich2/include/mpicxx.h:35:2: error: #error "SEEK_END is #defined but must 
not be for the C++ binding of MPI"

but when SEEK_* is not present and iostream has been included, OMPI-dev
gives these errors.

/home/ompi/include/openmpi/ompi/mpi/cxx/mpicxx.h:53: error: ‘SEEK_SET’ was not 
declared in this scope
/home/ompi/include/openmpi/ompi/mpi/cxx/mpicxx.h:54: error: ‘SEEK_CUR’ was not 
declared in this scope
/home/ompi/include/openmpi/ompi/mpi/cxx/mpicxx.h:55: error: ‘SEEK_END’ was not 
declared in this scope

There is a subtle difference between OMPI 1.2.7 and -dev at least with
GCC 4.3.2.  If iostream was included before mpi.h and then SEEK_* are
#undef'd then 1.2.7 succeeds while -dev fails with the message above.
If stdio.h is included and SEEK_* are #undef'd then both OMPI versions
fail.  MPICH2 requires in both cases that SEEK_* be #undef'd.

What do you recommend to remain portable?  Is this really an MPICH2
issue?  The standard doesn't seem to address this issue.  The MPICH2 FAQ
has this

http://www.mcs.anl.gov/research/projects/mpich2/support/index.php?s=faqs#cxxseek


Jed

Attachment: pgpDbo1XASXHc.pgp
Description: PGP signature

Reply via email to