with m,n declared "int", for me 2 warnings arise from this line:
first, "write" takes a size_t argument:
write(fd,vals,(size_t)(m*n)*sizeof(double))
and returns a "ssize_t" value, so the rest of the line compiles fine
like this:
!= (ssize_t)((size_t)(m*n)*sizeof(double)
which gives:
write(fd,vals,(size_t)(m*n)*sizeof(double)) !=
(ssize_t)((size_t)(m*n)*sizeof(double))
but that is somewhat ugly... :/
Eric
On 13/09/16 03:03 PM, Barry Smith wrote:
I need help from someone who knows the subtleties of c++. We have a PETSc
example that always compiles fine with C but generates annoying warnings with
C++. I've tried many different variants to eliminate the warnings with no luck
Any help is appreciated.
Barry
mpicxx -o ex45.o -c -Wall -Wwrite-strings -Wno-strict-aliasing
-Wno-unknown-pragmas -fvisibility=hidden -g -O -fPIC
-I/sandbox/petsc/petsc.clone-3/include
-I/sandbox/petsc/petsc.clone-3/arch-linux-opt-cxx-quad/include
-I/usr/include/mpich2 `pwd`/ex45.c
/sandbox/petsc/petsc.clone-3/src/mat/examples/tests/ex45.c: In function ‘void
Store2DArray(int, int, double*, const char*, int*)’:
/sandbox/petsc/petsc.clone-3/src/mat/examples/tests/ex45.c:75:41: warning:
comparison between signed and unsigned integer expressions [-Wsign-compare]
if (write(fd,vals,m*n*sizeof(double)) != ((unsigned int)
(m*n))*sizeof(double)) abort();
^
/sandbox/petsc/petsc.clone-3/src/mat/examples/tests/ex45.c: In function ‘void
Store1DArray(int, double*, const char*, int*)’:
/sandbox/petsc/petsc.clone-3/src/mat/examples/tests/ex45.c:97:36: warning:
comparison between signed and unsigned integer expressions [-Wsign-compare]
if (write(fd,a,m*sizeof(double)) != ((unsigned int)m)*sizeof(double))
abort();
It can be found here
ftp://ftp.mcs.anl.gov/pub/petsc/nightlylogs/archive/2016/09/13/examples_next_arch-linux-opt-cxx-quad_grind.log