OK, I see. You have argv_p as type "a pointer to an array of pointer to char". That must prevent the compiler from converting the "array" to a "pointer". I think if you drop the parens around the "(*argv_p)", you'll get the same stylistic effect, but it won't prevent the compiler from converting the "[]" to "*", and that seems to silence the warning: cap:/nfs/san0/user/home/jdelsign>cat xxx.c void bill( char *((*p)[])) {} void john( char *( *p [])) {} main(int argc, char *argv[]) { bill(&argv); john(&argv); } cap:/nfs/san0/user/home/jdelsign>gcc xxx.c xxx.c: In function 'main': xxx.c:5: warning: passing argument 1 of 'bill' from incompatible pointer type cap:/nfs/san0/user/home/jdelsign> Cheers, John D. William Gropp wrote:
Here's the test case for everyone. No const.
int MPI_Init( int *argc_p, char *((*argv_p)[]) ); int main( int argc, char *argv[] ) { MPI_Init( &argc, &argv ); return 0; }
This gives a warning with my gcc:
GroppsMac3:MPI-3.0 gropp$ gcc -c f1.c f1.c: In function �main�: f1.c:4: warning: passing argument 2 of �MPI_Init� from incompatible pointer type
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
On Jul 24, 2012, at 10:17 AM, John DelSignore wrote:
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[]) { bar(&argv); foo(&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 cap:/nfs/san0/user/home/jdelsign>
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 [email protected] http://lists.mpi-forum.org/mailman/listinfo.cgi/mpi-forum
_______________________________________________ mpi-forum mailing list [email protected] http://lists.mpi-forum.org/mailman/listinfo.cgi/mpi-forum
_______________________________________________ mpi-forum mailing list [email protected] http://lists.mpi-forum.org/mailman/listinfo.cgi/mpi-forum