On Thu, Aug 15, 2013 at 11:33 PM, Xu, Yechuan <y...@neu.edu> wrote: > Thank you for your reply. after I read the xdrfile.c, > > I changed the sentence as > pos=xdr_getpos((XDR*) (xtc->xdr)); > > like that in the file of xdrfile.c. I also copy the definition > for XDR and xdr_op to my own code.
You can see those functions, but the fact that there's an opaque struct is a clue you're not supposed to want to use them. Your code has already read the frame using the public interface in xdrfile_xtc.h. What else are you trying to achieve? Mark > But I still got the errors: > seekxtc.c:61:33: error: dereferencing pointer to incomplete type > pos=xdr_getpos((XDR *)(xtc->xdr)); > ^ > > here are my code: > #include <stdio.h> > #include <stdlib.h> > #include <math.h> > #include <xdrfile_xtc.h> > > enum xdr_op > { > XDR_ENCODE = 0, > XDR_DECODE = 1, > XDR_FREE = 2 > }; > > typedef struct XDR XDR; > > struct XDR > { > enum xdr_op x_op; > struct xdr_ops > { > int (*x_getlong) (XDR *__xdrs, int32_t *__lp); > int (*x_putlong) (XDR *__xdrs, int32_t *__lp); > int (*x_getbytes) (XDR *__xdrs, char *__addr, unsigned int __len); > int (*x_putbytes) (XDR *__xdrs, char *__addr, unsigned int __len); > /* two next routines are not 64-bit IO safe - don't use! */ > unsigned int (*x_getpostn) (XDR *__xdrs); > int (*x_setpostn) (XDR *__xdrs, unsigned int __pos); > void (*x_destroy) (XDR *__xdrs); > } > *x_ops; > char *x_private; > }; > > > int main(int argc, char *argv[]) > { > int i; > int step, read_return, result; > int natoms; > float time,prec=1000.; > matrix box; > rvec *x; > XDRFILE *xtc; > char *fname; > unsigned int pos; > > printf("begin, argc=%d\n",argc); > if(argc==2){ > fname=argv[1]; > } > > xtc=xdrfile_open (fname,"r"); > read_xtc_natoms (fname,&natoms); > printf("number of atoms: %d\n",natoms); > > x = calloc(natoms, sizeof (x[0])); > > while(1){ > read_return=read_xtc(xtc,natoms,&step,&time,box,x,&prec); > if (read_return!=0) break; > > pos=xdr_getpos((XDR *)(xtc->xdr)); > printf("%d\n",pos); > > } > > xdrfile_close (xtc); > } > Thanks, > YC > > > On Aug 15, 2013, at 3:09 PM, Mark Abraham wrote: > >> Right, because a pointer to an XDRFILE is neither a struct nor a union >> :-) Look at how these routines are used, and consult the header files >> for the right types to give them. >> >> Mark >> >> On Thu, Aug 15, 2013 at 7:29 PM, Xu, Yechuan <y...@neu.edu> wrote: >>> Hi Everyone, >>> >>> I want to read a certain frame in a xtc file. How can I do that? >>> I see there are xdr_getpos() and xdr_setpos(). How should I use >>> these functions? >>> >>> I tried: >>> >>> XDRFILE *xtc; >>> unsigned int pos; >>> >>> pos=xdr_getpos(xtc.xdr); >>> >>> but I got: >>> error: request for member ‘xdr’ in something not a structure or union >>> >>> Thanks in advance. >>> YC-- >>> gmx-users mailing list gmx-users@gromacs.org >>> http://lists.gromacs.org/mailman/listinfo/gmx-users >>> * Please search the archive at >>> http://www.gromacs.org/Support/Mailing_Lists/Search before posting! >>> * Please don't post (un)subscribe requests to the list. Use the >>> www interface or send it to gmx-users-requ...@gromacs.org. >>> * Can't post? Read http://www.gromacs.org/Support/Mailing_Lists >> -- >> gmx-users mailing list gmx-users@gromacs.org >> http://lists.gromacs.org/mailman/listinfo/gmx-users >> * Please search the archive at >> http://www.gromacs.org/Support/Mailing_Lists/Search before posting! >> * Please don't post (un)subscribe requests to the list. Use the >> www interface or send it to gmx-users-requ...@gromacs.org. >> * Can't post? Read http://www.gromacs.org/Support/Mailing_Lists > > -- > gmx-users mailing list gmx-users@gromacs.org > http://lists.gromacs.org/mailman/listinfo/gmx-users > * Please search the archive at > http://www.gromacs.org/Support/Mailing_Lists/Search before posting! > * Please don't post (un)subscribe requests to the list. Use the > www interface or send it to gmx-users-requ...@gromacs.org. > * Can't post? Read http://www.gromacs.org/Support/Mailing_Lists -- gmx-users mailing list gmx-users@gromacs.org http://lists.gromacs.org/mailman/listinfo/gmx-users * Please search the archive at http://www.gromacs.org/Support/Mailing_Lists/Search before posting! * Please don't post (un)subscribe requests to the list. Use the www interface or send it to gmx-users-requ...@gromacs.org. * Can't post? Read http://www.gromacs.org/Support/Mailing_Lists