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

Barry Smith bsmith at mcs.anl.gov
Sun Nov 17 21:43:34 CST 2013


   Can we really write function pointers to a binary file? And what C is this?

  } 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);
  }

src/snes/utils/dmsnes.c: In function ‘DMSNESView’:
src/snes/utils/dmsnes.c:58:5: warning: initializer element is not computable at load time [enabled by default]
     } funcstruct = {kdm->ops->computefunction,kdm->ops->computejacobian};
     ^
src/snes/utils/dmsnes.c:58:5: warning: initializer element is not computable at load time [enabled by default]

src/ts/utils/dmts.c: In function ‘DMTSView’:
src/ts/utils/dmts.c:69:5: warning: initializer element is not computable at load time [enabled by default]
     } funcstruct = {kdm->ops->ifunction,
     ^
src/ts/utils/dmts.c:70:21: warning: initializer element is not computable at load time [enabled by default]
                     kdm->ops->ifunctionview,
                     ^
src/ts/utils/dmts.c:71:21: warning: initializer element is not computable at load time [enabled by default]
                     kdm->ops->ifunctionload};
                     ^
src/ts/utils/dmts.c:76:5: warning: initializer element is not computable at load time [enabled by default]
     } jacstruct = {kdm->ops->ijacobian,
     ^
src/ts/utils/dmts.c:77:20: warning: initializer element is not computable at load time [enabled by default]
                    kdm->ops->ijacobianview,
                    ^
src/ts/utils/dmts.c:78:20: warning: initializer element is not computable at load time [enabled by default]
                    kdm->ops->ijacobianload};
                    ^

          CC arch-linux-c89/obj/src/ts/impls/implicit/gl/gladapt.o
src/ts/impls/eimex/eimex.c: In function ‘TSSetFromOptions_EIMEX’:
src/ts/impls/eimex/eimex.c:464:3: warning: initializer element is not computable at load time [enabled by default]
   PetscInt       tindex[2]={TSEIMEXDefault,TSEIMEXDefault};
   ^
src/ts/impls/eimex/eimex.c:464:3: warning: initializer element is not computable at load time [enabled by default]





More information about the petsc-dev mailing list