[C++-sig] Strange Behavior w/File Pointers

Michael Wieher michael.wieher at gmail.com
Fri Mar 7 16:43:51 CET 2008


istream globalFile;
struct dataStruct {
   int a;
   int b;
   short c;
} __attribute__(align(2));

PyObject *
mYmodule_setFile() {

PyObject *
mYmodule_getNBytesAtATime() {
  int N;  //the size of a dataStruct
  Py_BuildValue('ii',dataStruct->a, dataStruct->b);

Given the above rough pseudocode, I find that each time my Python module
calls myModule.getNBytesAtATime() the file-pointer shifts strangely.  Most
of the time it shifts N bytes.  But, sometimes, on the same points but with
no definable reason that I can see, it shifts N*x bytes, where x is some

I've fixed the problem by manually resetting the file-pointer on re-entry to
getNBytesAtATime, so the code works, but if anyone can shed some light on
this little quirk, I'd be interested.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20080307/a531f237/attachment.htm>

More information about the Cplusplus-sig mailing list