Re: [Mpi-forum] Giving up on C11 _Generic

2019-08-07 Thread Jim Dinan via mpi-forum
This example is a bit more representative of how we would use this to implement the MPI bindings (renamed "bar" macro to "foo" and shifted down to enable the name aliasing): #include static void foo(int j) { printf("foo(j) = %d\n", j); } #define foo(j) foo(sizeof(j) > sizeof(int) ? -1

Re: [Mpi-forum] Giving up on C11 _Generic

2019-08-07 Thread Jim Dinan via mpi-forum
Jeff, You can wrap the function in a macro that checks for truncation: #include #define bar(j) foo(sizeof(j) > sizeof(int) ? -1 : j) static void foo(int j) { printf("foo(j) = %d\n", j); } int main(int argc, char *argv[]) { /* 8589934592LL == 2^33 */ long long i =

Re: [Mpi-forum] Giving up on C11 _Generic

2019-08-07 Thread Jim Dinan via mpi-forum
Even simpler than this, we could just forward all calls to the MPI_Count interface (see below). The int count argument should type convert to MPI_Count without issue. Note that it still needs to be a function-like macro so that function pointers work. Don't give up yet! :D ~Jim. #include

Re: [Mpi-forum] Giving up on C11 _Generic

2019-08-07 Thread Jim Dinan via mpi-forum
10 PM Jim Dinan via mpi-forum < > mpi-forum@lists.mpi-forum.org> wrote: > >> Even simpler than this, we could just forward all calls to the MPI_Count >> interface (see below). The int count argument should type convert to >> MPI_Count without issue. Note that it still

Re: [Mpi-forum] Giving up on C11 _Generic

2019-08-08 Thread Jim Dinan via mpi-forum
In fairness, unsafe conversions are a feature of the C language, I assume since very early on. Assignment gets a pass to do horribly unsafe conversions. Unfortunately, when calling a function (with a prototype), the argument expressions are converted as if by assignment, which is the underlying

Re: [Mpi-forum] Giving up on C11 _Generic

2019-08-08 Thread Jim Dinan via mpi-forum
9BT > — > The University of Edinburgh is a charitable body, registered in Scotland, > with registration number SC005336. > — > > On 7 Aug 2019, at 22:00, Jim Dinan via mpi-forum < > mpi-forum@lists.mpi-forum.org> wrote: > > Even simpler than this, we could just forw