[mpich-discuss] Nifty workaround for SEEK_SET issues
Jeff Squyres
jsquyres at cisco.com
Fri Sep 5 13:47:02 CDT 2008
Per our discussion in Dublin, here's a nifty solution for the
MPI::SEEK_SET issue that was proposed Doug Gregor from Indiana:
mpicxx.h:
#include <stdio.h>
const int your_mpi_stdio_seek_set = (SEEK_SET);
#undef SEEK_SET
const int SEEK_SET = your_mpi_stdio_seek_set;
(and the same for the others)
Since the stdio_seek_set variable is const, this is basically an end-
run around the preprocessor but the compiler will still treat it like
a *constant* (it will likely not even generate a symbol for it). Doug
felt that every compiler would get this right, but we put a "static"
on those two declarations, just to be sure.
Note that we found that we also need to #include <iostream> after
<stdio.h> but before smashing SEEK_SET for obscure reasons on Linux
(using SEEK_SET as an enum value), so you need to force its inclusion
early. A bummer, but it's an imperfect world...
Note that Solaris 10u6 just introduced a new #define named LOCK_SHARED
from <sys/asynch.h>) that conflicts with MPI::LOCK_SHARED. A similar
approach can be used there. The logic gets a little more complex
because you need to conditionally include <sys/asynch.h> (which seems
to only exist on Solaris) so that you can smash the LOCK_SHARED macro.
--
Jeff Squyres
Cisco Systems
More information about the mpich-discuss
mailing list