Jeff responded:
>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'm not so sure, although the difference may not be relevent in
practise. Referring to the ANSI C Standard (I don't have a copy
of the ISO version of the document...), section 3.3.4 covers this
case:
"An arbitrary integer may be converted to a pointer. The
result is implementation defined." (p. 46, ll.34,35)
Similar language applying, with additional qualifications due to
integer's size, to the reverse operation appears on p. 46,
ll. 30-33. You're allowed to do it, but it doesn't have to work.
By constrast, the C standard does make promises about conversions
between pointer types. (You can do it and it does have to work.)
For example:
"... It is guaranteed, however, that a pointer to an object of
given alignment may be converted to a pointer to an object of the
same alignment or a less strict alignment and back again; the
result shall compare equal to the original pointer...."
(p. 47,l. 37 - p. 48, l. 2)
Admittedly, this is picky legalese, but we are writing a standards
document. :)
- Ian
-- Ian E. Stockdale MRJ Technology Solutions, NASA Ames Research Center ies@nas.nasa.gov (415) 604-4628