[petsc-dev] Compliant C89

Matthew Knepley knepley at gmail.com
Mon Jan 14 09:07:23 CST 2013


On Mon, Jan 14, 2013 at 9:02 AM, Jed Brown <jedbrown at mcs.anl.gov> wrote:

> 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?
>

Yes, definitely.

  Matt


> Regardless, Satish, can you set up a build --with-64-bit-indices
> CFLAGS='-std=c89 -pedantic -Wno-long-long'?
>



-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20130114/3e88f890/attachment.html>


More information about the petsc-dev mailing list