[petsc-dev] Compliant C89

Jed Brown jedbrown at mcs.anl.gov
Mon Jan 14 09:02:42 CST 2013


The cast macros like PetscBLASIntCast() are not "safe" in that they include
two separate statements. Unfortunately, we cannot do better with C89 unless
we pass the target as an argument. Regardless, these casts *cannot* be used
in declarations.

PetscBLASInt   one = 1,bn = PetscBLASIntCast(xin->map->n);
PetscErrorCode ierr;

This is invalid C89 because once the macro expands, there is a statement
before the next declaration. Furthermore, the check calls SETERRQ in case
of failure, so it *must* be inside a PetscFunctionBegin/PetscFunctionReturn
block.

Should we change this cast to an inline function (or equivalent macro) so
that this usage is more explicit?

Regardless, Satish, can you set up a build --with-64-bit-indices
CFLAGS='-std=c89 -pedantic -Wno-long-long'?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20130114/837822e4/attachment.html>


More information about the petsc-dev mailing list