Re: New errhandler text

Jeff Squyres (jsquyres@lsc.nd.edu)
Wed, 7 May 1997 12:36:15 -0500 (EST)

On Wed, 7 May 1997, Dick Treumann wrote:

> Does not Jeff's proposal imply that an MPI object handle is "really"
> a pointer to the object. If an MPI_Comm is really a Comm_Obj* and an
> MPI_Win is a Win_Obj* then both can be passed as void*. The MPI
> standard is explicit in saying they NEED NOT BE POINTERS.

No -- anything can be passed through (void *), including an int. All you
have to do is cast it to the Right Thing. For example:

int
My_comm_attr_fn(void *comm_arg, int keyval, void *extra_state, void
*val_in, void *val_out, int *flag)
{
MPI_Comm real_comm = (MPI_Comm) comm_arg;
}

Note that the "real" type of MPI_Comm is irrelevant here.

> I think suitable use of casting can solve the problem in C
> but I do not know for C++. Within my MPI implementation's
> C code which calls these functions I will need to cast my
> handle to void* to be able to pass it to such a callback.

Correct, although many compilers will implcitly cast anything to (void *).

> If the impact in C++ is no worse then I have no objection.

Actually, I'm glad you brought that up... (imagine that the C++ person
neglected to check his own bindings!) The object passed into the C++ user
callbacks would have to be a *pointer* to the handle instead of the actual
handle. You can't pass a struct/class through (void *). There would need
to be text added about that.

{+} Jeff Squyres
{+} squyres@cse.nd.edu
{+} Perpetual Obsessive Notre Dame Student Craving Utter Madness
{+} "I came to ND for 4 years and ended up staying for a decade"