In the upcoming 1.0.8 release of MPICH2 (next week or so) we are fixing it similar to Open MPI, so you shouldn't need to undef anything even in MPICH2.
Rajeev > Date: Thu, 16 Oct 2008 12:29:01 +0200 > From: Jed Brown <j...@59a2.org> > Subject: [OMPI users] on SEEK_* > To: us...@open-mpi.org > Message-ID: <20081016102901.gg10...@brakk.ethz.ch> > Content-Type: text/plain; charset="utf-8" > > 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 > -------------- next part -------------- > A non-text attachment was scrubbed... > Name: not available > Type: application/pgp-signature > Size: 197 bytes > Desc: not available > URL: > <http://www.open-mpi.org/MailArchives/users/attachments/200810 > 16/96b11669/attachment.bin> > > ------------------------------ > > Message: 4 > Date: Thu, 16 Oct 2008 07:43:54 -0400 > From: Jeff Squyres <jsquy...@cisco.com> > Subject: Re: [OMPI users] on SEEK_* > To: Open MPI Users <us...@open-mpi.org> > Message-ID: <a843c2d8-18fa-421e-ba45-1a4b4551a...@cisco.com> > Content-Type: text/plain; charset=WINDOWS-1252; format=flowed; > delsp=yes > > On Oct 16, 2008, at 6:29 AM, Jed Brown wrote: > > > 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. > > Open MPI doesn't require undef'ing of anything. It should also not > require any special ordering of include files. Specifically, the > following codes both compile fine for me with 1.2.8 and the OMPI SVN > trunk (which is what I assume you mean by "-dev"?): > > #include <iostream> > #include <mpi.h> > int a = MPI::SEEK_SET; > > and > > #include <mpi.h> > #include <iostream> > int a = MPI::SEEK_SET; > > So in short: don't #undef anything and OMPI should do the > Right things. > > > 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 > > > This is actually a problem in the MPI-2 spec; the names > "MPI::SEEK_SET" (and friends) were unfortunately chosen poorly. > Hopefully that'll be fixed relatively soon, in MPI-2.2. > > MPICH chose to handle this situation a different way than we > did, and > apparently requires that you either #undef something or you > #define an > MPICH-specific macro. I guess the portable way might be to just > always define that MPICH-specific macro. It should be harmless for > OMPI. > > FWIW, I was chatting with the MPICH developers at the recent > MPI Forum > meeting and showed them how we did our SEEK_* solution in Open MPI. > > -- > Jeff Squyres > Cisco Systems > > > > > ------------------------------ >