[Tutor] Re: Making Python modules with C

Derrick 'dman' Hudson dman@dman.ddts.net
Sat, 15 Jun 2002 17:51:26 -0500


--VbJkn9YxBvnuCH5J
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sat, Jun 15, 2002 at 03:55:25PM +0700, Mico Siahaan wrote:
| At 11:23 PM 6/14/2002 -0700, you wrote:
=20
| >I did a quick scan through the Python README file, and there's a chance
| >that cygwin will work for you.  Cygwin is a port of the GCC tools to
| >Windows, and you can find out more information here:
| >
| >    http://sources.redhat.com/cygwin/
|=20
| I used gcc (cygwin) and got this error message:
|=20
| In file included from include/Python.h:54, from spammodule.c:1:
| include/pyport.h:422: #error "LONG_BIT definition appears wrong for=20
| platform (ba
| d gcc/glibc config?)."
|=20
| What does it mean? Ang how to solve it?

Last time I saw that error message, it was on a RH 7.0 machine and it
was caused by a buggy libc.

Here's the code that is causing that :

#if LONG_BIT !=3D 8 * SIZEOF_LONG
/* 04-Oct-2000 LONG_BIT is apparently (mis)defined as 64 on some recent
 * 32-bit platforms using gcc.  We try to catch that here at compile-time
 * rather than waiting for integer multiplication to trigger bogus
 * overflows.
 */
#error "LONG_BIT definition appears wrong for platform (bad gcc/glibc confi=
g?)."
#endif


Python's build system is built to figure out what the limits of the
basic C data types are on your platform (because C isn't very precise
about it).  Python needs that information so it can properly detect
and handle overflows and stuff like that.

I have an x86 system (ia32), so for me the relvant sizes are :

    LONG_MAX    2147483647=20
    LONG_BIT    32=20
    SIZEOF_LONG 4=20

That RH 7.0 box I mentioned had LONG_BIT set to 64, which is why
python barfed ( 4*64 !=3D 2147483647 ).

The best solution is to get a fixed libc, but on that RH box I simply
modified /usr/include/bits/xopen_lim.h to set LONG_BIt to the correct
value. =20

HTH,
-D

--=20

Better a little with righteousness
than much gain with injustice.
        Proverbs 16:8
=20
http://dman.ddts.net/~dman/


--VbJkn9YxBvnuCH5J
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iEYEARECAAYFAj0LxO4ACgkQO8l8XBKTpRTVnwCgm1/DysGxBmnP1TpJHJqrCIim
GtAAoJAl8T8Id8zbvoQbWeY3BppGuUWH
=sofc
-----END PGP SIGNATURE-----

--VbJkn9YxBvnuCH5J--