[Python-Dev] [Python-checkins] r43028 - python/trunk/Modules/_ctypes/cfield.c

Neal Norwitz nnorwitz at gmail.com
Wed Mar 15 22:41:37 CET 2006


On 3/15/06, Tim Peters <tim.peters at gmail.com> wrote:
>
> [Neal Norwitz]
> > This isn't exactly correct.  On a 64-bit system, the value will be
> > cast into a 32-bit integer.  This is true for both Win64 and Unix.  If
> > you change the cast to a long and use %ld (lowercase ell), that will
> > work correctly on Unix, but not Win64.  To always display the correct
> > value on all platforms, you need an #ifdef MS_WIN64.  For Windows, you
> > use %Id (that's a capital letter eye) and reference the value without
> > a cast.  For Unix, you use %ld (lowercase ell), and cast the value to
> > a (long) to avoid a warning.
>
> I'm copying this to python-dev because it's important people
> understand this :-):  all of the above is kinda true but irrelevant.

Whoops, my comment only applies to *printf(), not PyString's as you
correctly point out.

For an example, see the definition for PRINT_TOTAL_REFS() in 
http://svn.python.org/view/python/trunk/Python/pythonrun.c?rev=42876&view=markup

n
--

> Martin already checked in a patch so that PyString_FromFormat()
> understands the C99 "z" qualifier on _all_ platforms.  So the correct
> way to repair this one wasn't to add a cast, and much less to add an
> #ifdef, it was to change
>
>      ofs=%d
>
> to
>
>      ofs=%zd
>
> in the format.  I'm going to check that change in now, but don't make
> me do it again :-)
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/nnorwitz%40gmail.com
>


More information about the Python-Dev mailing list