<br><br><div><span class="gmail_quote">On 8/21/06, <b class="gmail_sendername">Alexander Belopolsky</b> <<a href="mailto:alexander.belopolsky@gmail.com">alexander.belopolsky@gmail.com</a>> wrote:</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Here is a similar problem:<br>typedef struct {<br> ...<br> size_t pos;<br> ...<br>} mmap_object;<br>...<br>mmap_tell_method(mmap_object *self, PyObject *unused)<br>{<br> CHECK_VALID(NULL);<br> return PyInt_FromLong((long) self->pos);
<br>}<br><br>See Modules/mmapmodule.c .<br><br>Here a cast to ssize_t would, technically speaking, not be safe<br>either, but it may be worth using ssize_t anyways.</blockquote><div><br>It should call PyInt_FromSize_t, without any casting. That will make it a PyLong if it's bigger than a Py_ssize_t, too.
<br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Is there a simple automated way to detect situations like this? Maybe<br>there is a win64 compiler that would generate a warning.
<br></blockquote></div><br>I doubt it. Explicit casts are meant to silence warnings (among other things.) Warning for all casts is bound to generate quite a lot of warnings.<br><br>-- <br>Thomas Wouters <<a href="mailto:thomas@python.org">
thomas@python.org</a>><br><br>Hi! I'm a .signature virus! copy me into your .signature file to help me spread!