[petsc-dev] strange illegal struct initialization and binary storage of function pointers

Jed Brown jedbrown at mcs.anl.gov
Mon Nov 18 01:22:06 CST 2013


Barry Smith <bsmith at mcs.anl.gov> writes:

>    Can we really write function pointers to a binary file? 

Not in general.  I don't know how you planned for it to work.

>    And what C is this?

Any dialect after C89.  Simple fix is declare and then assign rather
than assign in the initializer.  Which compiler is producing these
messages?

>   } else if (isbinary) {
>     struct {
>       PetscErrorCode (*func)(SNES,Vec,Vec,void*);
>       PetscErrorCode (*jac)(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
>     } funcstruct = {kdm->ops->computefunction,kdm->ops->computejacobian};
>     ierr = PetscViewerBinaryWrite(viewer,&funcstruct,2,PETSC_FUNCTION,PETSC_FALSE);CHKERRQ(ierr);
>   }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20131118/7402122a/attachment.sig>


More information about the petsc-dev mailing list