[Mpi-forum] Compile problems with examples in MPI Standard

John DelSignore John.DelSignore at roguewave.com
Tue Jul 24 10:17:33 CDT 2012

In C and C++, the type of "char *argv[]" as a parameter is equivalent to the type of "char **argv", because you can't pass an array as an argument. Therefore, as written in the example, the type of argv is "a pointer to a pointer to a char".

I don't know what the type signature of MPI_Init() is in your implementation, but it's possible that a "const" got tossed in there somewhere, for example: int MPI_Init(int *, const char ***);

Here's a simple test:

cap:/nfs/san0/user/home/jdelsign>cat xxx.c
void bar(      char ***p) {}
void foo(const char ***p) {}
main(int argc, char *argv[])
cap:/nfs/san0/user/home/jdelsign>gcc --version | head -1
gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-44)
cap:/nfs/san0/user/home/jdelsign>gcc xxx.c
xxx.c: In function 'main':
xxx.c:6: warning: passing argument 1 of 'foo' from incompatible pointer type

Hope this helps.

Cheers, John D.

William Gropp wrote:
> I've run my code checker over the examples in the MPI-3 Standard, and I've found some issues.  Perhaps the biggest is this (a typical example):
> Opening file one-side-2.tex
> ex5501.c: In function ‘main’:
> ex5501.c:58: warning: passing argument 2 of ‘MPI_Init’ from incompatible pointer type
> This occurs everywhere we include MPI_Init in an example.  The compiler is gcc 4.2.1 .  The corresponding 
> declaration of argv is as intended:
> int main(int argc, char *argv[]) 
> The declaration in MPI_Init looks correct (argv is a pointer to an array of pointers to char).  Is this a place where we should stick with the *** notation just to keep compilers happy?  Or is there something I'm missing in the declaration?
> There are a number of other errors as well.  Three examples in the new tools chapter don't compile.  There are a number of problems in the datatype chapter, most minor.
> I can fix the obvious ones or leave them to the chapter authors.  Let me know what is preferred.
> I can't check the Fortran 08 examples because I only have gfortran :( 
> Bill
> William Gropp
> Director, Parallel Computing Institute
> Deputy Director for Research
> Institute for Advanced Computing Applications and Technologies
> Paul and Cynthia Saylor Professor of Computer Science
> University of Illinois Urbana-Champaign
> _______________________________________________
> mpi-forum mailing list
> mpi-forum at lists.mpi-forum.org
> http://lists.mpi-forum.org/mailman/listinfo.cgi/mpi-forum

More information about the mpi-forum mailing list