[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [mpi-21] Proposal EH2: add const keyword to the C bindings
A similar problem (and maybe more frequent) will be with the MPI callback
functions (e.g. MPI_Op)
If we really want to implement const in all places where it makes sense,
-- for reasons of consistency and to help users avoid incorrect code --
we will break a lot of code:
For example: (MPI_Op_create)
The calling list for the user function type is
typedef void (MPI_User_function) ( void * a,
void * b, int * len, MPI_Datatype * );
Since a should only be read, to be consistent, void * a should actually be
const void * a;
Making this modification would surely help catch bugs.
Also -- not related to the const issue -- it is rather strange that len
is passed by a pointer, since 'len' isn't meant to be modified? Applying
the rule would yield 'const int * len', which is a rather strange (and
inefficient) way to pass an integer.
The attribute copy function is immune:
there the original attribute is passed by value (casted
to void *), and hence doesn't need an added const;
(Well one could argue that it does need a const, but it will be casted to
something else anyway)
Dries